From f37d724a9e2171996f05fb6fd6227f8e26a17c18 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 1 Sep 2008 01:54:00 +0000 Subject: [PATCH] Merged revisions 3080-3081,3084,3087-3088,3090,3092,3099-3103,3113-3114,3132,3134-3143,3145,3148-3151,3154-3159,3165,3174,3194,3234-3235,3239-3240,3244,3246-3254,3258-3262,3268,3270,3274,3279,3286-3288,3294-3295 from 1.0 branch via svnmerge --- chrome.manifest | 2 +- .../content/zotero/bindings/timedtextarea.xml | 24 +- chrome/content/zotero/browser.js | 44 +- chrome/content/zotero/charsetMenu.js | 26 +- chrome/content/zotero/exportOptions.js | 23 +- chrome/content/zotero/overlay.js | 58 +- chrome/content/zotero/overlay.xul | 3 +- .../content/zotero/preferences/preferences.js | 7 +- .../zotero/preferences/preferences.xul | 21 + chrome/content/zotero/tools/csledit.xul | 2 +- chrome/content/zotero/tools/cslpreview.xul | 2 +- chrome/content/zotero/xpcom/annotate.js | 1664 +++-- chrome/content/zotero/xpcom/attachments.js | 29 +- chrome/content/zotero/xpcom/cite.js | 4 +- chrome/content/zotero/xpcom/data/item.js | 3 + chrome/content/zotero/xpcom/file.js | 7 +- chrome/content/zotero/xpcom/mime.js | 2 + chrome/content/zotero/xpcom/search.js | 3 +- chrome/content/zotero/xpcom/translate.js | 262 +- chrome/content/zotero/xpcom/utilities.js | 726 +- chrome/content/zotero/xpcom/zotero.js | 120 +- chrome/locale/en-US/zotero/preferences.dtd | 4 + chrome/locale/en-US/zotero/zotero.dtd | 1 - chrome/locale/en-US/zotero/zotero.properties | 1 + .../default/zotero/annotate-add-selected.png | Bin 771 -> 657 bytes chrome/skin/default/zotero/annotate-add.png | Bin 682 -> 530 bytes .../default/zotero/annotate-collapse-all.png | Bin 670 -> 0 bytes .../skin/default/zotero/annotate-collapse.png | Bin 0 -> 557 bytes .../default/zotero/annotate-expand-all.png | Bin 678 -> 0 bytes .../zotero/annotate-highlight-selected.png | Bin 1060 -> 788 bytes .../default/zotero/annotate-highlight.png | Bin 987 -> 927 bytes .../zotero/annotate-unhighlight-selected.png | Bin 3591 -> 845 bytes .../default/zotero/annotate-unhighlight.png | Bin 3520 -> 976 bytes chrome/skin/default/zotero/annotation.css | 54 + chrome/skin/default/zotero/annotation.html | 16 + chrome/skin/default/zotero/overlay.css | 7 +- .../default/zotero/report/detail_screen.css | 1 - components/zotero-protocol-handler.js | 52 +- defaults/preferences/zotero.js | 2 + scrapers.sql | 6610 ++++++++++++++++- 40 files changed, 8402 insertions(+), 1378 deletions(-) delete mode 100644 chrome/skin/default/zotero/annotate-collapse-all.png create mode 100644 chrome/skin/default/zotero/annotate-collapse.png delete mode 100644 chrome/skin/default/zotero/annotate-expand-all.png create mode 100644 chrome/skin/default/zotero/annotation.css create mode 100644 chrome/skin/default/zotero/annotation.html diff --git a/chrome.manifest b/chrome.manifest index 5d9ce78470..24b4516ff5 100644 --- a/chrome.manifest +++ b/chrome.manifest @@ -10,7 +10,7 @@ locale zotero cs-CZ chrome/locale/cs-CZ/zotero/ locale zotero da-DK chrome/locale/da-DK/zotero/ locale zotero de-AT chrome/locale/de-AT/zotero/ locale zotero de-CH chrome/locale/de-CH/zotero/ -locale zotero de-DE chrome/locale/de-DE/zotero/ +locale zotero de chrome/locale/de-DE/zotero/ locale zotero el-GR chrome/locale/el-GR/zotero/ locale zotero es-ES chrome/locale/es-ES/zotero/ locale zotero et-EE chrome/locale/et-EE/zotero/ diff --git a/chrome/content/zotero/bindings/timedtextarea.xml b/chrome/content/zotero/bindings/timedtextarea.xml index f7eb05790a..35cd8759e4 100644 --- a/chrome/content/zotero/bindings/timedtextarea.xml +++ b/chrome/content/zotero/bindings/timedtextarea.xml @@ -136,20 +136,22 @@ - + ]]> diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index c701e5cf3f..4d7fcc97c9 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -41,7 +41,7 @@ var Zotero_Browser = new function() { this.scrapeThisPage = scrapeThisPage; this.annotatePage = annotatePage; this.toggleMode = toggleMode; - this.setCollapsed = setCollapsed; + this.toggleCollapsed = toggleCollapsed; this.chromeLoad = chromeLoad; this.chromeUnload = chromeUnload; this.contentLoad = contentLoad; @@ -141,8 +141,6 @@ var Zotero_Browser = new function() { else { var tab = _getTabObject(this.tabbrowser.selectedBrowser); } - tab.annotateNextLoad = true; - tab.annotateID = id; } /* @@ -182,9 +180,9 @@ var Zotero_Browser = new function() { /* * expands all annotations */ - function setCollapsed(status) { + function toggleCollapsed() { var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser); - tab.page.annotations.setCollapsed(status); + tab.page.annotations.toggleCollapsed(); } /* @@ -340,34 +338,26 @@ var Zotero_Browser = new function() { var tab = _getTabObject(browser); if(isHTML) { - if(tab.annotateNextLoad) { - if(Zotero.Annotate.isAnnotated(tab.annotateID)) { + var annotationID = Zotero.Annotate.getAnnotationIDFromURL(browser.currentURI.spec); + if(annotationID) { + if(Zotero.Annotate.isAnnotated(annotationID)) { window.alert(Zotero.getString("annotations.oneWindowWarning")); - } else { + } else if(!tab.page.annotations) { // enable annotation - tab.page.annotations = new Zotero.Annotations(this, browser, tab.annotateID); - Zotero.Annotate.setAnnotated(tab.annotateID, true); - browser.contentWindow.addEventListener('beforeunload', function() { - // save annotations - try { - tab.page.annotations.save(); - } catch(e) { - throw(e); - } finally { - Zotero.Annotate.setAnnotated(tab.page.annotations.itemID, false); - } - }, false); + tab.page.annotations = new Zotero.Annotations(this, browser, annotationID); + var saveAnnotations = function() { + tab.page.annotations.save(); + tab.page.annotations = undefined; + }; + browser.contentWindow.addEventListener('beforeunload', saveAnnotations, false); + browser.contentWindow.addEventListener('close', saveAnnotations, false); + tab.page.annotations.load(); } } } // detect translators tab.detectTranslators(rootDoc, doc); - - // clear annotateNextLoad - if(tab.annotateNextLoad) { - tab.annotateNextLoad = tab.annotateID = undefined; - } } /* @@ -410,7 +400,7 @@ var Zotero_Browser = new function() { // To execute if document object does not exist _deleteTabObject(event.target.linkedBrowser); - toggleMode(null); + toggleMode(); } @@ -556,7 +546,7 @@ var Zotero_Browser = new function() { if(selection.isCollapsed) return; if(type == "highlight") { - tab.page.annotations.createHighlight(selection.getRangeAt(0)); + tab.page.annotations.highlight(selection.getRangeAt(0)); } else if(type == "unhighlight") { tab.page.annotations.unhighlight(selection.getRangeAt(0)); } diff --git a/chrome/content/zotero/charsetMenu.js b/chrome/content/zotero/charsetMenu.js index 47f2f0cbe9..97b3622b3b 100644 --- a/chrome/content/zotero/charsetMenu.js +++ b/chrome/content/zotero/charsetMenu.js @@ -28,9 +28,9 @@ Zotero_Charset_Menu = new function() { * closer to the top * * @param {DOMElement} charsetMenu The menu to populate - * @param {Boolean} showEndian Whether to show endian (e.g., UTF-32) options + * @param {Boolean} exportMenu Whether the menu is to be used for export **/ - function populate(charsetMenu, showEndian) { + function populate(charsetMenu, exportMenu) { var charsetMap = {}; // get charset popup and charset RDF @@ -60,16 +60,16 @@ Zotero_Charset_Menu = new function() { var isUTF16 = charset.length >= 6 && charset.substr(0, 6) == "UTF-16"; - // Show UTF-16 element appropriately depending on showEndian - if(isUTF16 && showEndian == (charset == "UTF-16") || - (!showEndian && charset == "UTF-32LE")) { + // Show UTF-16 element appropriately depending on exportMenu + if(isUTF16 && exportMenu == (charset == "UTF-16") || + (!exportMenu && charset == "UTF-32LE")) { continue; } else if(charset == "x-mac-roman") { // use the IANA name - value = "macintosh"; - } else if(!showEndian && charset == "UTF-32BE") { + charset = "macintosh"; + } else if(!exportMenu && charset == "UTF-32BE") { label = "Unicode (UTF-32)"; - value = "UTF-32"; + charset = "UTF-32"; } // add element @@ -85,7 +85,7 @@ Zotero_Charset_Menu = new function() { var oldFirst = (charsetPopup.firstChild ? charsetPopup.firstChild : null); charsetPopup.insertBefore(itemNode, oldFirst); // also add (without BOM) if requested - if(showEndian) { + if(exportMenu) { var itemNode = document.createElement("menuitem"); itemNode.setAttribute("label", Zotero.getString("charset.UTF8withoutBOM")); itemNode.setAttribute("value", charset+"xBOM"); @@ -97,6 +97,14 @@ Zotero_Charset_Menu = new function() { } } + if(!exportMenu) { + var itemNode = document.createElement("menuitem"); + itemNode.setAttribute("label", Zotero.getString("charset.autoDetect")); + itemNode.setAttribute("value", "auto"); + charsetMap["auto"] = itemNode; + charsetPopup.insertBefore(itemNode, charsetPopup.firstChild); + } + return charsetMap; } } \ No newline at end of file diff --git a/chrome/content/zotero/exportOptions.js b/chrome/content/zotero/exportOptions.js index a88cc4d896..c5f0ad169d 100644 --- a/chrome/content/zotero/exportOptions.js +++ b/chrome/content/zotero/exportOptions.js @@ -36,7 +36,7 @@ var Zotero_File_Interface_Export = new function() { this.accept = accept; this.cancel = cancel; - var _charsets; + var _charsets = false; /* * add options to export @@ -100,7 +100,9 @@ var Zotero_File_Interface_Export = new function() { } // from charsetMenu.js - _charsets = Zotero_Charset_Menu.populate(document.getElementById(OPTION_PREFIX+"exportCharset"), true); + if(Zotero.Prefs.get("export.displayCharsetOption")) { + _charsets = Zotero_Charset_Menu.populate(document.getElementById(OPTION_PREFIX+"exportCharset"), true); + } updateOptions(Zotero.Prefs.get("export.translatorSettings")); } @@ -156,11 +158,11 @@ var Zotero_File_Interface_Export = new function() { } // handle charset popup - var charsetMenu = document.getElementById(OPTION_PREFIX+"exportCharset"); - if(translatorOptions.exportCharset) { - document.getElementById("charset-box").hidden = undefined; + if(_charsets && translatorOptions.exportCharset) { optionsBox.hidden = undefined; - var charset = "UTF-8xBOM"; + document.getElementById("charset-box").hidden = undefined; + var charsetMenu = document.getElementById(OPTION_PREFIX+"exportCharset"); + var charset = "UTF-8"; if(options && options.exportCharset && _charsets[options.exportCharset]) { charset = options.exportCharset; } else if(translatorOptions.exportCharset && _charsets[translatorOptions.exportCharset]) { @@ -168,6 +170,8 @@ var Zotero_File_Interface_Export = new function() { } charsetMenu.selectedItem = _charsets[charset]; + } else { + document.getElementById("charset-box").hidden = true; } window.sizeToContent(); @@ -192,17 +196,16 @@ var Zotero_File_Interface_Export = new function() { var element = document.getElementById(OPTION_PREFIX+option); if(option == "exportCharset") { - optionsAvailable[option] = element.selectedItem.value; + if(_charsets) { + optionsAvailable[option] = element.selectedItem.value; + } } else if(typeof(defValue) == "boolean") { optionsAvailable[option] = !!element.checked; } } // save options - Zotero.debug("EXPORT OPTIONS"); - Zotero.debug(optionsAvailable); optionString = Zotero.JSON.serialize(optionsAvailable); - Zotero.debug(optionString); Zotero.Prefs.set("export.translatorSettings", optionString); } diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 6898c5f82c..3dc7af92c8 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -850,6 +850,7 @@ var ZoteroPane = new function() // Create a element, essentially else { + label.removeAttribute('value'); label.appendChild(document.createTextNode(val)); } @@ -863,11 +864,35 @@ var ZoteroPane = new function() var checkState = { value: Zotero.Prefs.get('lastRenameAssociatedFile') }; while (true) { - var result = nsIPS.prompt(window, + // Don't show "Rename associated file" option for + // linked URLs + if (linkMode = item.ref.getAttachmentLinkMode() == + Zotero.Attachments.LINK_MODE_LINKED_URL) { + var result = nsIPS.prompt( + window, + '', + Zotero.getString('pane.item.attachments.rename.title'), + newTitle, + null, + {} + ); + + // If they hit cancel or left it blank + if (!result || !newTitle.value) { + return; + } + + break; + } + + var result = nsIPS.prompt( + window, + '', Zotero.getString('pane.item.attachments.rename.title'), - '', newTitle, + newTitle, Zotero.getString('pane.item.attachments.rename.renameAssociatedFile'), - checkState); + checkState + ); // If they hit cancel or left it blank if (!result || !newTitle.value) { @@ -1701,36 +1726,13 @@ var ZoteroPane = new function() var tab = gBrowser.addTab(uri); var browser = gBrowser.getBrowserForTab(tab); - if (data && data.attachmentID) { - Zotero_Browser.annotatePage(data.attachmentID, browser); - // In case the page has already loaded, update - Zotero_Browser.updateStatus(); - } - if (event.shiftKey) { gBrowser.selectedTab = tab; } - } - else if (event.shiftKey) { + } else if (event.shiftKey) { window.open(uri, "zotero-loaded-page", "menubar=yes,location=yes,toolbar=yes,personalbar=yes,resizable=yes,scrollbars=yes,status=yes"); - - if (data && data.attachmentID) { - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); - var newWindow = wm.getMostRecentWindow("navigator:browser"); - //var browser = newWindow.getBrowser(); - - newWindow.Zotero_Browser.annotatePage(data.attachmentID); - // In case the page has already loaded, update - newWindow.Zotero_Browser.updateStatus(); - } - } - else { - if (data && data.attachmentID) { - // Enable annotation - Zotero_Browser.annotatePage(data.attachmentID); - } + } else { window.loadURI(uri); } } diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index f4d487f129..6346cfc939 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -404,8 +404,7 @@