From 07028650f07c037ef33f1eaece36879be166c5db Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 19 Feb 2012 18:32:32 -0500 Subject: [PATCH] Closes #48, Additional field in QuickFormat dialog showing the name of the library and providing a link to the item with the following modifications - Open in current window if one is already open - Use a button instead of a label - Don't show button if citation item is not linked to a Zotero item This doesn't currently work if the Zotero pane has never been opened in the given window, because ZoteroPane.selectItem() appears to fail in that circumstance. This needs to be fixed. --- .../zotero-platform/mac/integration.css | 14 +++++++++ .../content/zotero/integration/quickFormat.js | 31 ++++++++++++++----- .../zotero/integration/quickFormat.xul | 4 ++- chrome/content/zotero/xpcom/integration.js | 1 + chrome/locale/en-US/zotero/zotero.properties | 1 + chrome/skin/default/zotero/integration.css | 6 +++- 6 files changed, 48 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero-platform/mac/integration.css b/chrome/content/zotero-platform/mac/integration.css index 34f1a8de4..a8aab911b 100644 --- a/chrome/content/zotero-platform/mac/integration.css +++ b/chrome/content/zotero-platform/mac/integration.css @@ -79,4 +79,18 @@ body[multiline="true"] { #citation-properties menulist > .menulist-dropmarker > .dropmarker-icon { list-style-image: url("chrome://browser/skin/hud-style-dropmarker-double-arrows.png"); +} + +panel button { + -moz-appearance: none; color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,.5); border-radius: 12px; border: 1px solid rgba(0,0,0,.65); background: -moz-linear-gradient(rgba(110,110,110,.9), rgba(70,70,70,.9) 49%, rgba(50,50,50,.9) 51%, rgba(40,40,40,.9)); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), inset 0 0 1px rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.1); background-clip: padding-box; background-origin: padding-box; padding: 2px 9px; + margin: 6px; + min-height: 22px; +} + +panel button:hover:active { + background: -moz-linear-gradient(rgba(40,40,40,.9), rgba(70,70,70,.9)); box-shadow: inset 0 0 3px rgba(0,0,0,.2), inset 0 1px 7px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.1); +} + +panel button:-moz-focusring { + box-shadow: 0 0 1px -moz-mac-focusring inset, 0 0 4px 1px -moz-mac-focusring, 0 0 2px 1px -moz-mac-focusring; } \ No newline at end of file diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index 1474459f3..3cadabf41 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -36,7 +36,7 @@ var Zotero_QuickFormat = new function () { keepSorted, showEditor, referencePanel, referenceBox, referenceHeight = 0, separatorHeight = 0, currentLocator, currentLocatorLabel, currentSearchTime, dragging, panel, panelPrefix, panelSuffix, panelSuppressAuthor, panelLocatorLabel, panelLocator, - panelInfo, panelRefersToBubble, panelFrameHeight = 0, accepted = false; + panelLibraryLink, panelInfo, panelRefersToBubble, panelFrameHeight = 0, accepted = false; // A variable that contains the timeout object for the latest onKeyPress event var eventTimeout = null; @@ -912,12 +912,12 @@ var Zotero_QuickFormat = new function () { while(panelInfo.hasChildNodes()) panelInfo.removeChild(panelInfo.firstChild); _buildItemDescription(item, panelInfo); - var libraryName = item.libraryID ? Zotero.Libraries.getName(item.libraryID) - : Zotero.getString('pane.collections.library'); - var libraryLink = document.getElementById("citation-properties-library-link"); - //TODO: Localize "Open in " - libraryLink.textContent ="Open in "+libraryName; - libraryLink.onclick=function() {window.open('zotero://select/item/'+(item.libraryID ? item.libraryID : 0)+'_'+item.key)}; + panelLibraryLink.hidden = !item.id; + if(item.id) { + var libraryName = item.libraryID ? Zotero.Libraries.getName(item.libraryID) + : Zotero.getString('pane.collections.library'); + panelLibraryLink.textContent = Zotero.getString("integration.openInLibrary", libraryName); + } target.setAttribute("selected", "true"); panel.openPopup(target, "after_start", @@ -1190,6 +1190,23 @@ var Zotero_QuickFormat = new function () { accepted = true; } + /** + * Show an item in the library it came from + */ + this.showInLibrary = function() { + var id = panelRefersToBubble.citationItem.id; + var pane = Zotero.getActiveZoteroPane(); + if(pane) { + pane.show(); + pane.selectItem(id); + } else { + var win = window.open('zotero://select/item/'+id); + } + + // Pull window to foreground + Zotero.Integration.activate(pane.document.defaultView); + } + /** * Resizes windows * @constructor diff --git a/chrome/content/zotero/integration/quickFormat.xul b/chrome/content/zotero/integration/quickFormat.xul index c94e9a7a4..e9935e6b4 100644 --- a/chrome/content/zotero/integration/quickFormat.xul +++ b/chrome/content/zotero/integration/quickFormat.xul @@ -78,7 +78,6 @@ - @@ -113,6 +112,9 @@ + +