diff --git a/chrome/content/zotero-platform/mac/integration.css b/chrome/content/zotero-platform/mac/integration.css new file mode 100644 index 000000000..9f37dcb4f --- /dev/null +++ b/chrome/content/zotero-platform/mac/integration.css @@ -0,0 +1,83 @@ +body { + line-height: 1.45em; +} + +body[multiline="true"] { + line-height: 1.63em; +} + +#quick-format-dialog { + background: transparent; + -moz-appearance: none; + padding: 0; +} + +#quick-format-search { + height: 22px; + background: white; + -moz-appearance: searchfield; +} + +#quick-format-search[multiline="true"] { + padding: 2px 2px 0 18px; + border: 1px solid rgba(0, 0, 0, 0.5); + border-radius: 10px; + -moz-appearance: none; +} + +#quick-format-search:not([multiline="true"]) { + height: 22px !important; +} + +#quick-format-search[multiline="true"] > #quick-format-iframe { + margin: -1px 0 0 0; +} + +#quick-format-entry { + background: -moz-linear-gradient(-90deg, rgb(243,123,119) 0, rgb(180,47,38) 50%, rgb(156,36,27) 50%); + -moz-border-radius:15px; + padding: 10px; +} + +#zotero-icon { + margin: 0 0 0 -13px; +} + +#citation-properties menulist { + -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; + border-radius: 3px; + min-height: 22px; + -moz-padding-start: 4px; + -moz-padding-end: 0; +} + +#citation-properties menulist:-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; +} + +#citation-properties menulist[open="true"], +#citation-properties menulist: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); +} + +#citation-properties menulist > .menulist-dropmarker { + -moz-appearance: none; + display: -moz-box; + background-color: transparent; + border: 0; + margin: 0; + padding: 0; +} + +#citation-properties menulist > .menulist-dropmarker > .dropmarker-icon { + list-style-image: url("chrome://browser/skin/hud-style-dropmarker-double-arrows.png"); +} \ No newline at end of file diff --git a/chrome/content/zotero-platform/unix/integration.css b/chrome/content/zotero-platform/unix/integration.css new file mode 100644 index 000000000..e69de29bb diff --git a/chrome/content/zotero-platform/win/integration.css b/chrome/content/zotero-platform/win/integration.css new file mode 100644 index 000000000..bf6a5d4b8 --- /dev/null +++ b/chrome/content/zotero-platform/win/integration.css @@ -0,0 +1,42 @@ +#quick-format-dialog { + background: transparent; + -moz-appearance: -moz-win-borderless-glass; + padding: 0; +} + +#quick-format-search { + background: white; + padding: 2px 2px 2px 0; + border: 1px solid rgba(0, 0, 0, 0.5); + border-radius: 10px; + -moz-appearance: none; +} + +#quick-format-dialog { + background: transparent; + -moz-appearance: none; + padding: 0; +} + +#quick-format-search:not([multiline="true"]) { + height: 28px !important; +} + +#quick-format-entry { + background: -moz-linear-gradient(-90deg, rgb(243,123,119) 0, rgb(180,47,38) 50%, rgb(156,36,27) 50%); + -moz-border-radius:15px; + padding: 10px; +} + +#zotero-icon { + margin: 2px 0 0 2px; + -moz-appearance: none; +} + +body { + line-height: 1.65em; +} + +body[multiline="true"] { + padding-bottom: 2px; +} \ No newline at end of file diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index b4480c891..dfaae7bf8 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -35,16 +35,16 @@ var Zotero_QuickFormat = new function () { this.onDOMContentLoaded = function() { io = window.arguments[0].wrappedJSObject; + // Only hide chrome on Windows or Mac + if(Zotero.isMac || Zotero.isWin) { + document.documentElement.setAttribute("hidechrome", true); + } + qfs = document.getElementById("quick-format-search"); qfi = document.getElementById("quick-format-iframe"); qfb = document.getElementById("quick-format-entry"); qfbHeight = qfb.scrollHeight; referencePanel = document.getElementById("quick-format-reference-panel"); - referencePanel.addEventListener("popuphidden", _refocusQfe, false); - referencePanel.addEventListener("popupshown", _refocusQfe, false); - referencePanel.addEventListener("focus", _refocusQfe, false); - referencePanel.addEventListener("activate", _refocusQfe, false); - referencePanel.addEventListener("keypress", _onReferencePanelKeypress, false); referenceBox = document.getElementById("quick-format-reference-list"); qfiWindow = qfi.contentWindow; qfiDocument = qfi.contentDocument; @@ -103,6 +103,7 @@ var Zotero_QuickFormat = new function () { function _refocusQfe() { window.focus(); qfe.focus(); + referencePanel.blur(); } /** @@ -421,18 +422,19 @@ var Zotero_QuickFormat = new function () { var numReferences = referenceBox.childNodes.length, height; var qfeHeight = qfe.scrollHeight; - if(qfeHeight > 20) { - var height = (22-16+qfeHeight+(qfs.style.height == "22px" ? 2 : -2)); - window.resizeTo(window.innerWidth, height+20); - qfs.style.height = height+"px"; - qfe.style.lineHeight = "18px"; + if(qfeHeight > 30) { + qfe.setAttribute("multiline", true); qfs.setAttribute("multiline", true); - } else { - var height = 22; - window.resizeTo(window.innerWidth, height+20); + qfeHeight = qfe.scrollHeight; + var height = 4+qfeHeight; + qfs.style.height = height+"px"; - qfe.style.lineHeight = "16px"; + window.sizeToContent(); + } else { + delete qfs.style.height; + qfe.removeAttribute("multiline"); qfs.removeAttribute("multiline"); + window.sizeToContent(); } var panelShowing = referencePanel.state === "open" || referencePanel.state === "showing"; @@ -441,12 +443,12 @@ var Zotero_QuickFormat = new function () { var height = referenceHeight ? Math.min(numReferences, SHOWN_REFERENCES)*referenceHeight+2 : 39; if(panelShowing && height !== referencePanel.clientHeight) { - referencePanel.sizeTo((window.innerWidth-30), height); + referencePanel.sizeTo((window.outerWidth-30), height); /*if(curResizer) curResizer.stop(); curResizer = new Resizer(referencePanel, null, height, 30, 1000); curResizer.animate();*/ } else { - referencePanel.sizeTo((window.innerWidth-30), height); + referencePanel.sizeTo((window.outerWidth-30), height); referencePanel.openPopup(document.documentElement, "after_start", 15, null, false, false, null); @@ -454,7 +456,6 @@ var Zotero_QuickFormat = new function () { referenceHeight = referenceBox.firstChild.scrollHeight; height = Math.min(numReferences, SHOWN_REFERENCES)*referenceHeight+2; referencePanel.sizeTo((window.innerWidth-30), height); - window.setTimeout(_refocusQfe, 100); } } } else { @@ -634,79 +635,77 @@ var Zotero_QuickFormat = new function () { * Handle return or escape */ function _onQuickSearchKeyPress(event) { - try { - var keyCode = event.keyCode; - if(keyCode === event.DOM_VK_RETURN || keyCode === event.DOM_VK_ENTER) { + var keyCode = event.keyCode; + if(keyCode === event.DOM_VK_RETURN || keyCode === event.DOM_VK_ENTER) { + event.preventDefault(); + if(!_bubbleizeSelected()) { + _accept(); + } + } else if(keyCode === event.DOM_VK_TAB || event.charCode === 59 /* ; */) { + event.preventDefault(); + _bubbleizeSelected(); + } else if(keyCode === event.DOM_VK_BACK_SPACE) { + _resize(); + } else if(keyCode === event.DOM_VK_UP) { + var selectedItem = referenceBox.selectedItem; + var previousSibling; + if((previousSibling = selectedItem.previousSibling)) { + referenceBox.selectedItem = previousSibling; + referenceBox.ensureElementIsVisible(previousSibling); event.preventDefault(); - if(!_bubbleizeSelected()) { - _accept(); - } - } else if(keyCode === event.DOM_VK_TAB || event.charCode === 59 /* ; */) { - event.preventDefault(); - _bubbleizeSelected(); - } else if(keyCode === event.DOM_VK_UP) { - var selectedItem = referenceBox.selectedItem; - var previousSibling; - if((previousSibling = selectedItem.previousSibling)) { - referenceBox.selectedItem = previousSibling; - referenceBox.ensureElementIsVisible(previousSibling); - event.preventDefault(); - }; - } else if(keyCode === event.DOM_VK_DOWN) { - if((Zotero.isMac ? event.metaKey : event.ctrlKey)) { - // If meta key is held down, show the citation properties panel - var selection = qfiWindow.getSelection(); - var range = selection.getRangeAt(0); - - // Check whether the bubble is selected - var endContainer = range.endContainer; - if(endContainer !== qfe) { - if(range.endContainer.citationItem) { - _showCitationProperties(range.endContainer); - } else if(endContainer.nodeType === Node.TEXT_NODE) { - if(endContainer.parentNode === qfe) { - var node = endContainer; - while((node = endContainer.previousSibling)) { - if(node.citationItem) { - _showCitationProperties(node); - event.preventDefault(); - return; - } + }; + } else if(keyCode === event.DOM_VK_DOWN) { + if((Zotero.isMac ? event.metaKey : event.ctrlKey)) { + // If meta key is held down, show the citation properties panel + var selection = qfiWindow.getSelection(); + var range = selection.getRangeAt(0); + + // Check whether the bubble is selected + var endContainer = range.endContainer; + if(endContainer !== qfe) { + if(range.endContainer.citationItem) { + _showCitationProperties(range.endContainer); + } else if(endContainer.nodeType === Node.TEXT_NODE) { + if(endContainer.parentNode === qfe) { + var node = endContainer; + while((node = endContainer.previousSibling)) { + if(node.citationItem) { + _showCitationProperties(node); + event.preventDefault(); + return; } } } + } + event.preventDefault(); + return; + } + + // Check whether there is a bubble in the range + var endOffset = range.endOffset; + var childNodes = qfe.childNodes; + for(var i=Math.min(endOffset, childNodes.length-1); i>=0; i--) { + var node = childNodes[i]; + if(node.citationItem) { + _showCitationProperties(node); event.preventDefault(); return; } - - // Check whether there is a bubble in the range - var endOffset = range.endOffset; - var childNodes = qfe.childNodes; - for(var i=Math.min(endOffset, childNodes.length-1); i>=0; i--) { - var node = childNodes[i]; - if(node.citationItem) { - _showCitationProperties(node); - event.preventDefault(); - return; - } - } - - event.preventDefault(); - } else { - var selectedItem = referenceBox.selectedItem; - var nextSibling; - if((nextSibling = selectedItem.nextSibling)) { - referenceBox.selectedItem = nextSibling; - referenceBox.ensureElementIsVisible(nextSibling); - event.preventDefault(); - }; } + + event.preventDefault(); } else { - // Use a timeout so that _quickFormat gets called after update - window.setTimeout(_quickFormat, 0); + var selectedItem = referenceBox.selectedItem; + var nextSibling; + if((nextSibling = selectedItem.nextSibling)) { + referenceBox.selectedItem = nextSibling; + referenceBox.ensureElementIsVisible(nextSibling); + event.preventDefault(); + }; } - } catch(e) { - Zotero.logError(e); + } else { + // Use a timeout so that _quickFormat gets called after update + window.setTimeout(_quickFormat, 0); } } diff --git a/chrome/content/zotero/integration/quickFormat.xul b/chrome/content/zotero/integration/quickFormat.xul index f3d6e0dbf..0252d15dc 100644 --- a/chrome/content/zotero/integration/quickFormat.xul +++ b/chrome/content/zotero/integration/quickFormat.xul @@ -25,22 +25,19 @@ --> - - - + + onkeypress="Zotero_QuickFormat.onKeyPress(event)">