Fixes #32, implement tags in tags tab

This commit is contained in:
David Norton 2006-07-05 13:09:58 +00:00
parent 07e75aa9de
commit 7333a1b538
3 changed files with 62 additions and 4 deletions

View file

@ -4,6 +4,7 @@ ScholarItemPane = new function()
var _creatorTypeMenu;
var _beforeRow;
var _notesList;
var _tagsList;
var _notesLabel;
var _creatorCount;
@ -21,6 +22,8 @@ ScholarItemPane = new function()
this.modifyCreator = modifyCreator;
this.removeNote = removeNote;
this.addNote = addNote;
this.removeTag = removeTag;
this.addTag = addTag;
function onLoad()
{
@ -29,6 +32,7 @@ ScholarItemPane = new function()
_creatorTypeMenu = document.getElementById('creatorTypeMenu');
_notesList = document.getElementById('editpane-dynamic-notes');
_notesLabel = document.getElementById('editpane-notes-label');
_tagsList = document.getElementById('editpane-dynamic-tags');
var creatorTypes = Scholar.CreatorTypes.getTypes();
for(var i = 0; i < creatorTypes.length; i++)
@ -121,7 +125,7 @@ ScholarItemPane = new function()
label.setAttribute('value',_noteToTitle(notes[i].getNote()));
label.setAttribute('crop','end');
box = document.createElement('box');
var box = document.createElement('box');
box.setAttribute('onclick',"ScholarPane.openNoteWindow("+notes[i].getID()+");");
box.setAttribute('class','clicky');
box.appendChild(icon);
@ -139,7 +143,38 @@ ScholarItemPane = new function()
_notesList.appendChild(row);
}
}
_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);
}
}
}
function changeTypeTo(id)
@ -352,6 +387,18 @@ 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);

View file

@ -31,7 +31,7 @@
<vbox flex="1">
<hbox align="center">
<label id="editpane-notes-label"/>
<button label="New Note" oncommand="ScholarItemPane.addNote();"/>
<button label="Add Note" oncommand="ScholarItemPane.addNote();"/>
</hbox>
<grid flex="1">
<columns>
@ -41,8 +41,19 @@
<rows id="editpane-dynamic-notes" flex="1"/>
</grid>
</vbox>
<vbox align="center" pack="center">
<label value="Coming soon"/>
<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>
</vbox>
<vbox align="center" pack="center">
<label value="Coming soon"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B