commit 1cdd1f3de238f725b6a05a78187ff8f5fc5d8126
parent 7333a1b538c832f56965d4a84aad1d33fc20bc49
Author: David Norton <david@nortoncrew.com>
Date: Wed, 5 Jul 2006 15:08:24 +0000
Fixes #24, tags for notes.
This is now a new control, <tagsbox> which is pretty darn portable.
Diffstat:
4 files changed, 135 insertions(+), 55 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/customControls.xml b/chrome/chromeFiles/content/scholar/customControls.xml
@@ -68,6 +68,8 @@
this.item = Scholar.Items.get(this.note.getNoteSource());
document.getAnonymousNodes(this)[0].childNodes[1].setAttribute('value',this.note.getNote());
+ document.getAnonymousNodes(this)[0].lastChild.firstChild.item = this.note;
+ this.updateTagsSummary();
]]>
</setter>
</property>
@@ -98,6 +100,22 @@
]]>
</body>
</method>
+ <method name="updateTagsSummary">
+ <body>
+ <![CDATA[
+ var popup = document.getAnonymousNodes(this)[0].lastChild;
+ var label = popup.previousSibling;
+ var v = popup.firstChild.summary;
+
+ if(!v || v == "")
+ v = "[click here]";
+
+ while(label.hasChildNodes())
+ label.removeChild(label.firstChild);
+ label.appendChild(document.createTextNode("Tags: " + v));
+ ]]>
+ </body>
+ </method>
</implementation>
<handlers>
</handlers>
@@ -106,7 +124,115 @@
<xul:label/>
<xul:textbox multiline="true" type="timed" timeout="1000" flex="1" oncommand="this.parentNode.parentNode.save();"/>
<xul:label value="See also: (coming soon)"/>
- <xul:label value="Tags: (coming soon)"/>
+ <xul:label onclick="this.nextSibling.showPopup(this,-1,-1,'popup',0,0);"/>
+ <xul:popup width="300" onpopuphidden="this.updateTagsSummary();">
+ <xul:tagsbox/>
+ </xul:popup>
+ </xul:vbox>
+ </content>
+ </binding>
+ <binding id="tags-box">
+ <implementation>
+ <field name="itemRef"/>
+ <property name="item" onget="return this.itemRef;">
+ <setter>
+ <![CDATA[
+ this.itemRef = val;
+
+ this.reloadTags();
+ ]]>
+ </setter>
+ </property>
+ <property name="summary">
+ <getter>
+ <![CDATA[
+ var r = "";
+
+ if(this.item)
+ {
+ var tags = this.item.getTags();
+ for(var i = 0; i < tags.length; i++)
+ {
+ r = r + Scholar.Tags.getName(tags[i]) + ", ";
+ }
+ r = r.substr(0,r.length-2);
+ }
+
+ return r;
+ ]]>
+ </getter>
+ </property>
+ <method name="reloadTags">
+ <body>
+ <![CDATA[
+ var rows = document.getAnonymousNodes(this)[0].lastChild.lastChild;
+ while(rows.hasChildNodes())
+ rows.removeChild(rows.firstChild);
+
+ if(this.item)
+ {
+ var tags = this.item.getTags();
+
+ for(var i = 0; i < tags.length; i++)
+ {
+ var icon= document.createElement("image");
+ icon.setAttribute('src','chrome://scholar/skin/tag.png');
+
+ var label = document.createElement("label");
+ label.setAttribute('value', Scholar.Tags.getName(tags[i]));
+
+ var remove = document.createElement("label");
+ remove.setAttribute('value','-');
+ remove.setAttribute('onclick',"this.parentNode.parentNode.parentNode.parentNode.parentNode.removeTag('"+tags[i]+"');");
+ remove.setAttribute('class','clicky');
+
+ var row = document.createElement("row");
+ row.appendChild(icon);
+ row.appendChild(label);
+ row.appendChild(remove);
+
+ rows.appendChild(row);
+ }
+ }
+ ]]>
+ </body>
+ </method>
+ <method name="addTag">
+ <body>
+ <![CDATA[
+ t = prompt('Add Tag:');
+ if(t && this.item)
+ {
+ this.item.addTag(t);
+ this.reloadTags();
+ }
+ ]]>
+ </body>
+ </method>
+ <method name="removeTag">
+ <parameter name="id"/>
+ <body>
+ <![CDATA[
+ if(id)
+ {
+ this.item.removeTag(id);
+ this.reloadTags();
+ }
+ ]]>
+ </body>
+ </method>
+ </implementation>
+ <content>
+ <xul:vbox xbl:inherits="flex">
+ <xul:button label="Add Tag" oncommand="this.parentNode.parentNode.addTag();"/>
+ <xul:grid>
+ <xul:columns>
+ <xul:column/>
+ <xul:column flex="1"/>
+ <xul:column/>
+ </xul:columns>
+ <xul:rows/>
+ </xul:grid>
</xul:vbox>
</content>
</binding>
diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js
@@ -22,8 +22,6 @@ ScholarItemPane = new function()
this.modifyCreator = modifyCreator;
this.removeNote = removeNote;
this.addNote = addNote;
- this.removeTag = removeTag;
- this.addTag = addTag;
function onLoad()
{
@@ -147,34 +145,7 @@ ScholarItemPane = new function()
_updateNoteCount();
//TAGS:
- while(_tagsList.hasChildNodes())
- _tagsList.removeChild(_tagsList.firstChild);
-
- var tags = _itemBeingEdited.getTags();
- if(tags.length)
- {
- for(var i = 0; i < tags.length; i++)
- {
- var icon = document.createElement('image');
- icon.setAttribute('src','chrome://scholar/skin/tag.png');
-
- var label = document.createElement('label');
- label.setAttribute('value',Scholar.Tags.getName(tags[i]));
- label.setAttribute('crop','end');
-
- var removeButton = document.createElement('label');
- removeButton.setAttribute("value","-");
- removeButton.setAttribute("class","clicky");
- removeButton.setAttribute("onclick","ScholarItemPane.removeTag("+tags[i]+")");
-
- var row = document.createElement('row');
- row.appendChild(icon);
- row.appendChild(label);
- row.appendChild(removeButton);
-
- _tagsList.appendChild(row);
- }
- }
+ _tagsList.item = _itemBeingEdited;
}
function changeTypeTo(id)
@@ -387,18 +358,6 @@ ScholarItemPane = new function()
_notesLabel.value = Scholar.getString('pane.item.notes.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
}
-
- function removeTag(id)
- {
- _itemBeingEdited.removeTag(id);
- }
-
- function addTag()
- {
- var t = prompt("Add Tag:");
- if(t)
- _itemBeingEdited.addTag(t);
- }
}
addEventListener("load", function(e) { ScholarItemPane.onLoad(e); }, false);
diff --git a/chrome/chromeFiles/content/scholar/itemPane.xul b/chrome/chromeFiles/content/scholar/itemPane.xul
@@ -42,18 +42,7 @@
</grid>
</vbox>
<vbox flex="1">
- <hbox align="center">
- <label id="editpane-tags-label"/>
- <button label="Add Tag" oncommand="ScholarItemPane.addTag();"/>
- </hbox>
- <grid flex="1">
- <columns>
- <column/>
- <column flex="1"/>
- <column/>
- </columns>
- <rows id="editpane-dynamic-tags" flex="1"/>
- </grid>
+ <tagsbox id="editpane-dynamic-tags" flex="1"/>
</vbox>
<vbox align="center" pack="center">
<label value="Coming soon"/>
diff --git a/chrome/chromeFiles/skin/default/scholar/scholar.css b/chrome/chromeFiles/skin/default/scholar/scholar.css
@@ -8,6 +8,12 @@ noteeditor
-moz-binding: url('chrome://scholar/content/customControls.xml#note-editor');
}
+tagsbox
+{
+ -moz-binding: url('chrome://scholar/content/customControls.xml#tags-box');
+}
+
+
#scholar-progress-box
{
border: 2px solid #7a0000;