Use red Z instead of search icon (this will probably become a popup menu)

This commit is contained in:
Simon Kornblith 2011-07-29 08:00:21 +00:00
parent 352a49723e
commit dce1298666
4 changed files with 40 additions and 22 deletions

View File

@ -24,7 +24,7 @@
*/ */
var Zotero_QuickFormat = new function () { var Zotero_QuickFormat = new function () {
var io, qft, qftWindow, qftDocument, qfe, var io, qfs, qfi, qfiWindow, qfiDocument, qfe,
qfb, qfbHeight, qfb, qfbHeight,
referenceBox, referenceHeight, referenceBox, referenceHeight,
dragX, dragY, curLocator, curLocatorLabel, dragX, dragY, curLocator, curLocatorLabel,
@ -35,14 +35,15 @@ var Zotero_QuickFormat = new function () {
* Initialize add citation dialog * Initialize add citation dialog
*/ */
this.onLoad = function() { this.onLoad = function() {
qft = document.getElementById("quick-format-search"); qfs = document.getElementById("quick-format-search");
qfi = document.getElementById("quick-format-iframe");
qfb = document.getElementById("quick-format-entry"); qfb = document.getElementById("quick-format-entry");
qfbHeight = qfb.scrollHeight; qfbHeight = qfb.scrollHeight;
referenceBox = document.getElementById("quick-format-reference-list"); referenceBox = document.getElementById("quick-format-reference-list");
qftWindow = qft.contentWindow; qfiWindow = qfi.contentWindow;
qftDocument = qft.contentDocument; qfiDocument = qfi.contentDocument;
qfb.addEventListener("keypress", _onQuickSearchKeyPress, false); qfb.addEventListener("keypress", _onQuickSearchKeyPress, false);
qfe = qftDocument.getElementById("quick-format-editor"); qfe = qfiDocument.getElementById("quick-format-editor");
qfe.focus(); qfe.focus();
// Add labels to popup // Add labels to popup
@ -65,8 +66,8 @@ var Zotero_QuickFormat = new function () {
io = window.arguments[0].wrappedJSObject; io = window.arguments[0].wrappedJSObject;
if(io.citation.citationItems.length) { if(io.citation.citationItems.length) {
// hack to get spacing right // hack to get spacing right
var evt = qftDocument.createEvent("KeyboardEvent"); var evt = qfiDocument.createEvent("KeyboardEvent");
evt.initKeyEvent("keypress", true, true, qftWindow, evt.initKeyEvent("keypress", true, true, qfiWindow,
0, 0, 0, 0, 0, 0, 0, 0,
0, " ".charCodeAt(0)) 0, " ".charCodeAt(0))
qfe.dispatchEvent(evt); qfe.dispatchEvent(evt);
@ -85,7 +86,7 @@ var Zotero_QuickFormat = new function () {
* Gets the content of the text node that the cursor is currently within * Gets the content of the text node that the cursor is currently within
*/ */
function _getCurrentEditorTextNode() { function _getCurrentEditorTextNode() {
var selection = qftWindow.getSelection(); var selection = qfiWindow.getSelection();
var range = selection.getRangeAt(0); var range = selection.getRangeAt(0);
var node = range.startContainer; var node = range.startContainer;
@ -171,6 +172,7 @@ var Zotero_QuickFormat = new function () {
} }
var s = new Zotero.Search(); var s = new Zotero.Search();
var haveConditions = false;
if(charRe.test(str)) { if(charRe.test(str)) {
Zotero.debug("QuickFormat: QuickSearch: "+str); Zotero.debug("QuickFormat: QuickSearch: "+str);
@ -348,7 +350,7 @@ var Zotero_QuickFormat = new function () {
// It's entirely unintuitive why, but after trying a bunch of things, it looks like using // It's entirely unintuitive why, but after trying a bunch of things, it looks like using
// a XUL label for these things works best. A regular span causes issues with moving the // a XUL label for these things works best. A regular span causes issues with moving the
// cursor. // cursor.
var bubble = qftDocument.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "label"); var bubble = qfiDocument.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "label");
bubble.setAttribute("class", "quick-format-bubble"); bubble.setAttribute("class", "quick-format-bubble");
bubble.setAttribute("value", str); bubble.setAttribute("value", str);
bubble.addEventListener("click", _onBubbleClick, false); bubble.addEventListener("click", _onBubbleClick, false);
@ -415,14 +417,15 @@ var Zotero_QuickFormat = new function () {
} }
if(height === window.innerHeight) return; if(height === window.innerHeight) return;
Zotero.debug(qfeHeight);
if(qfeHeight > 20) { if(qfeHeight > 20) {
qft.style.height = (22-16+qfeHeight+(qft.style.height == "22px" ? 2 : -2))+"px"; qfs.style.height = (22-16+qfeHeight+(qfi.style.height == "22px" ? 2 : -2))+"px";
qfe.style.lineHeight = "18px"; qfe.style.lineHeight = "18px";
qft.setAttribute("multiline", true); qfs.setAttribute("multiline", true);
} else { } else {
qft.style.height = "22px"; qfs.style.height = "22px";
qfe.style.lineHeight = "16px"; qfe.style.lineHeight = "16px";
qft.removeAttribute("multiline"); qfs.removeAttribute("multiline");
} }
if(curResizer) curResizer.stop(); if(curResizer) curResizer.stop();
curResizer = new Resizer(window, null, height, 10, 100); curResizer = new Resizer(window, null, height, 10, 100);
@ -495,7 +498,7 @@ var Zotero_QuickFormat = new function () {
*/ */
function _onBubbleDrag(event) { function _onBubbleDrag(event) {
// just in case // just in case
var el = qftDocument.getElementById("zotero-drag"); var el = qfiDocument.getElementById("zotero-drag");
if(el) el.parentNode.removeChild(el); if(el) el.parentNode.removeChild(el);
var dt = event.dataTransfer; var dt = event.dataTransfer;
@ -509,7 +512,7 @@ var Zotero_QuickFormat = new function () {
*/ */
function _onBubbleDrop(event) { function _onBubbleDrop(event) {
window.setTimeout(function() { window.setTimeout(function() {
var el = qftDocument.getElementById("zotero-drag"); var el = qfiDocument.getElementById("zotero-drag");
if(el) { if(el) {
_insertBubble(dragging, el); _insertBubble(dragging, el);
Zotero.debug(dragging); Zotero.debug(dragging);

View File

@ -47,10 +47,13 @@
<vbox id="zotero-select-items-container" flex="1"> <vbox id="zotero-select-items-container" flex="1">
<hbox id="quick-format-entry" ondragstart="Zotero_QuickFormat.onDragStart(this, event)"> <hbox id="quick-format-entry" ondragstart="Zotero_QuickFormat.onDragStart(this, event)">
<hbox id="quick-format-search" flex="1" align="start">
<image id="zotero-icon"/>
<!-- javascript:encodeURIComponent('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="chrome://zotero/skin/integration.css"/></head><body id="quick-format-editor"/></html>') --> <!-- javascript:encodeURIComponent('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="chrome://zotero/skin/integration.css"/></head><body id="quick-format-editor"/></html>') -->
<iframe id="quick-format-search" ondragstart="event.stopPropagation()" src="data:application/xhtml+xml,%3C!DOCTYPE%20html%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20XHTML%201.0%20Strict%2F%2FEN%22%20%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-strict.dtd%22%3E%3Chtml%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22%3E%3Chead%3E%3Clink%20rel%3D%22stylesheet%22%20type%3D%22text%2Fcss%22%20href%3D%22chrome%3A%2F%2Fzotero%2Fskin%2Fintegration.css%22%2F%3E%3C%2Fhead%3E%3Cbody%20contenteditable%3D%22true%22%20id%3D%22quick-format-editor%22%2F%3E%3C%2Fhtml%3E" <iframe id="quick-format-iframe" ondragstart="event.stopPropagation()" src="data:application/xhtml+xml,%3C!DOCTYPE%20html%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20XHTML%201.0%20Strict%2F%2FEN%22%20%22http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-strict.dtd%22%3E%3Chtml%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22%3E%3Chead%3E%3Clink%20rel%3D%22stylesheet%22%20type%3D%22text%2Fcss%22%20href%3D%22chrome%3A%2F%2Fzotero%2Fskin%2Fintegration.css%22%2F%3E%3C%2Fhead%3E%3Cbody%20contenteditable%3D%22true%22%20id%3D%22quick-format-editor%22%2F%3E%3C%2Fhtml%3E"
tabindex="1" flex="1"/> tabindex="1" flex="1"/>
</hbox> </hbox>
</hbox>
<richlistbox id="quick-format-reference-list" hidden="true" flex="1"/> <richlistbox id="quick-format-reference-list" hidden="true" flex="1"/>
</vbox> </vbox>
<panel id="citation-properties" type="arrow" orient="vertical" onkeypress="Zotero_QuickFormat.onPanelKeyPress(event)"> <panel id="citation-properties" type="arrow" orient="vertical" onkeypress="Zotero_QuickFormat.onPanelKeyPress(event)">

View File

@ -1804,7 +1804,7 @@ Zotero.Integration.Session.prototype.editCitation = function(index, noteIndex, c
io.style = this.style; io.style = this.style;
if(Zotero.Prefs.get("integration.quickFormat")) { if(Zotero.Prefs.get("integration.quickFormat")) {
this._displayDialog('chrome://zotero/content/integration/quickFormat.xul', io); this._displayDialog('chrome://zotero/content/integration/quickFormat.xul', '', io);
} else { } else {
this._displayDialog('chrome://zotero/content/integration/addCitationDialog.xul', 'resizable', io); this._displayDialog('chrome://zotero/content/integration/addCitationDialog.xul', 'resizable', io);
} }

View File

@ -143,12 +143,16 @@
} }
#quick-format-search[multiline="true"] { #quick-format-search[multiline="true"] {
padding: 1px 2px 0 18px; padding: 2px 2px 0 18px;
border: 1px solid rgba(0, 0, 0, 0.5); border: 1px solid rgba(0, 0, 0, 0.5);
border-radius: 8px; border-radius: 10px;
-moz-appearance: none; -moz-appearance: none;
} }
#quick-format-search[multiline="true"] > #quick-format-iframe {
margin: -1px 0 0 0;
}
body { body {
margin: 0 2px 0 2px; margin: 0 2px 0 2px;
padding: 0; padding: 0;
@ -228,3 +232,11 @@ richlistitem[selected="true"] {
#citation-properties menulist > .menulist-dropmarker > .dropmarker-icon { #citation-properties menulist > .menulist-dropmarker > .dropmarker-icon {
list-style-image: url("chrome://browser/skin/hud-style-dropmarker-double-arrows.png"); list-style-image: url("chrome://browser/skin/hud-style-dropmarker-double-arrows.png");
} }
#zotero-icon {
list-style-image: url("chrome://zotero/skin/zotero-new-z-16px.png");
width: 16px;
height: 16px;
background-color: #fff;
margin-left: -13px;
}