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.
This commit is contained in:
Simon Kornblith 2012-02-19 18:32:32 -05:00
parent 7a2e402d0d
commit 07028650f0
6 changed files with 48 additions and 9 deletions

View file

@ -80,3 +80,17 @@ 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;
}

View file

@ -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

View file

@ -78,7 +78,6 @@
<vbox flex="1">
<description id="citation-properties-title"/>
<hbox id="citation-properties-info"/>
<label id="citation-properties-library-link" onmouseover="event.target.style.cursor='pointer'" onmouseout="event.target.style.cursor='default'"/>
</vbox>
<grid flex="1">
<columns>
@ -113,6 +112,9 @@
</html:div>
</rows>
</grid>
<vbox flex="1" align="center">
<button id="citation-properties-library-link" onclick="Zotero_QuickFormat.showInLibrary()"/>
</vbox>
</panel>
<zoteroguidancepanel id="quick-format-guidance" about="quickFormat"
for="zotero-icon" x="26"/>

View file

@ -286,6 +286,7 @@ Zotero.Integration = new function() {
if(win) {
Components.utils.import("resource://gre/modules/ctypes.jsm");
win.focus();
if(!_carbon) {
_carbon = ctypes.open("/System/Library/Frameworks/Carbon.framework/Carbon");

View file

@ -589,6 +589,7 @@ integration.cited.loading = Loading Cited Items…
integration.ibid = ibid
integration.emptyCitationWarning.title = Blank Citation
integration.emptyCitationWarning.body = The citation you have specified would be empty in the currently selected style. Are you sure you want to add it?
integration.openInLibrary = Open in %S
integration.error.incompatibleVersion = This version of the Zotero word processor plugin ($INTEGRATION_VERSION) is incompatible with the currently installed version of Zotero (%1$S). Please ensure you are using the latest versions of both components.
integration.error.incompatibleVersion2 = Zotero %1$S requires %2$S %3$S or later. Please download the latest version of %2$S from zotero.org.

View file

@ -232,3 +232,7 @@ richlistitem[selected="true"] {
#citation-properties-info {
margin-bottom: 3px;
}
panel button .button-text {
margin: 0 !important;
}