commit 0fb1d5866f22b66285ce8eae5ebd8eed0fca5cda
parent b139882df1186427ec52ec771897c2fe457e03ba
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 13 Aug 2008 00:08:51 +0000
Fixes #1077, Add tag to note dialog broken
The manual Add Tag popup isn't popping up for me when I drag a note to the tag selector. If you're still getting that, please open a new ticket.
Diffstat:
4 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml
@@ -459,7 +459,7 @@
<xul:popup id="tagsPopup" ignorekeys="true"
onpopupshown="if (!document.commandDispatcher.focusedElement || document.commandDispatcher.focusedElement.tagName=='xul:label'){ /* DEBUG: it would be nice to make this work -- if (this.firstChild.count==0){ this.firstChild.new(); } */ this.setAttribute('showing', 'true'); }"
onpopuphidden="if (!document.commandDispatcher.focusedElement || document.commandDispatcher.focusedElement.tagName=='xul:label'){ this.setAttribute('showing', 'false'); }">
- <xul:tagsbox id="tags" flex="1"/>
+ <xul:tagsbox id="tags" flex="1" mode="edit"/>
</xul:popup>
</xul:popupset>
</xul:vbox>
diff --git a/chrome/content/zotero/bindings/tagsbox.xml b/chrome/content/zotero/bindings/tagsbox.xml
@@ -94,7 +94,13 @@
</getter>
</property>
-
+ <constructor>
+ <![CDATA[
+ if (this.hasAttribute('mode')) {
+ this.mode = this.getAttribute('mode');
+ }
+ ]]>
+ </constructor>
<method name="reload">
<body>
@@ -114,7 +120,7 @@
}
this.updateCount(tags.length);
- this.fixPopup();
+ //this.fixPopup();
return tags.length;
}
@@ -174,7 +180,7 @@
if (tagID)
{
remove.setAttribute('ztabindex', -1);
- remove.setAttribute('onclick',"this.parentNode.parentNode.parentNode.parentNode.parentNode.remove('"+ tagID +"');");
+ remove.setAttribute('onclick',"document.getBindingParent(this).remove('"+ tagID +"');");
}
else
{
@@ -321,6 +327,7 @@
this._tabDirection = 1;
var lastTag = true;
}
+
focused.blur();
// Return focus to items pane
@@ -355,8 +362,6 @@
case event.DOM_VK_TAB:
this._tabDirection = event.shiftKey ? -1 : 1;
- // Blur the old manually -- not sure why this is necessary,
- // but it prevents an immediate blur() on the next tag
focused.blur();
return false;
}
@@ -428,23 +433,21 @@
}
// New tag
else {
- // If this is an existing automatic tag, it's going to be
- // deleted and the number of rows will stay the same,
- // so we have to compensate
- var existingTypes = Zotero.Tags.getTypes(value);
- if (existingTypes && existingTypes.indexOf(1) != -1) {
+ var id = tagsbox.add(value);
+ if (!id) {
this._lastTabIndex--;
}
- var id = tagsbox.add(value);
}
}
if (id) {
elem = this.createValueElement(
value,
- 'tag',
tabindex
);
+
+ var box = textbox.parentNode;
+ box.replaceChild(elem, textbox);
}
else {
// Just remove the row
@@ -454,19 +457,11 @@
var row = rows.removeChild(row);
}
catch (e) {}
- tagsbox.fixPopup();
- tagsbox.closePopup();
-
- this._tabDirection = false;
- return;
}
var focusMode = 'tags';
var focusBox = tagsbox;
- var box = textbox.parentNode;
- box.replaceChild(elem,textbox);
-
if (this._tabDirection) {
this._focusNextField(focusBox, this._lastTabIndex, this._tabDirection == -1);
}
@@ -560,6 +555,7 @@
</method>
+ <!-- No longer used -->
<method name="fixPopup">
<body>
<![CDATA[
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js
@@ -2571,9 +2571,8 @@ Zotero.Item.prototype.addTag = function(name, type) {
if (type == 0 && existingTypes.indexOf(1) != -1) {
this.removeTag(Zotero.Tags.getID(name, 1));
}
- // If existing user and adding automatic, skip
- else if (type == 1 && existingTypes.indexOf(0) != -1) {
- Zotero.debug('Identical user tag already exists -- skipping automatic tag add');
+ else {
+ Zotero.debug('Identical tag already exists -- not adding tag');
Zotero.DB.commitTransaction();
return false;
}
@@ -2588,15 +2587,14 @@ Zotero.Item.prototype.addTag = function(name, type) {
}
try {
- var result = this.addTagByID(tagID);
+ this.addTagByID(tagID);
Zotero.DB.commitTransaction();
+ return tagID;
}
catch (e) {
Zotero.DB.rollbackTransaction();
throw (e);
}
-
- return result ? tagID : false;
}
diff --git a/chrome/content/zotero/xpcom/data/tag.js b/chrome/content/zotero/xpcom/data/tag.js
@@ -249,7 +249,7 @@ Zotero.Tag.prototype.save = function () {
Zotero.DB.query("UPDATE tags SET key=? WHERE tagID=?", [row.key, this.id]);
- Zotero.Tags.unload([{ oldID: { name: row.name, type: row.type } }]);
+ Zotero.Tags.unload(oldID);
Zotero.Notifier.trigger('id-change', 'tag', oldID + '-' + this.id);
// update caches