commit b94cf81ba38abd974b57e55480b5440a0eecfe06
parent fb9e803ab554b0400db9c86193416e67084b8d2a
Author: David Norton <david@nortoncrew.com>
Date: Mon, 26 Jun 2006 13:54:05 +0000
Trying this again:
Fixes #22, #26, #79, #71
Added remove note button, removed some old code.
Diffstat:
2 files changed, 22 insertions(+), 64 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js
@@ -19,10 +19,8 @@ ScholarItemPane = new function()
this.hideEditor = hideEditor;
this.modifyField = modifyField;
this.modifyCreator = modifyCreator;
- this.modifySelectedNote = modifySelectedNote;
- this.removeSelectedNote = removeSelectedNote;
+ this.removeNote = removeNote;
this.addNote = addNote;
- this.onNoteSelected = onNoteSelected;
function onLoad()
{
@@ -115,12 +113,26 @@ ScholarItemPane = new function()
{
for(var i = 0; i < notes.length; i++)
{
- var row = document.createElement('row');
+ var icon = document.createElement('image');
+ icon.setAttribute('src','chrome://scholar/skin/treeitem-note.png');
+
var button = document.createElement('label');
button.setAttribute('value',_noteToTitle(_itemBeingEdited.getNote(notes[i])));
- button.setAttribute('onclick',"window.open('chrome://scholar/content/note.xul?item="+_itemBeingEdited.getID()+"¬e="+notes[i]+"','','chrome,resizable,centerscreen');");
- button.setAttribute('class','clicky')
- row.appendChild(button);
+
+ box = document.createElement('box');
+ box.setAttribute('onclick',"window.open('chrome://scholar/content/note.xul?item="+_itemBeingEdited.getID()+"¬e="+notes[i]+"','','chrome,resizable,centerscreen');");
+ box.setAttribute('class','clicky');
+ box.appendChild(icon);
+ box.appendChild(button);
+
+ var removeButton = document.createElement('label');
+ removeButton.setAttribute("value","-");
+ removeButton.setAttribute("class","clicky");
+ removeButton.setAttribute("onclick","ScholarItemPane.removeNote("+notes[i]+")");
+
+ var row = document.createElement('row');
+ row.appendChild(box);
+ row.appendChild(removeButton);
_notesList.appendChild(row);
}
@@ -298,52 +310,14 @@ ScholarItemPane = new function()
_itemBeingEdited.save();
}
- function modifySelectedNote()
- {
- if(_notesMenu.selectedIndex == -1)
- return;
-
- var id = _selectedNoteID();
- if(id)
- {
- _itemBeingEdited.updateNote(id,_notesField.value);
- }
- else if(_notesField.value)//new note
- {
- id = _itemBeingEdited.addNote(_notesField.value);
- _notesMenu.selectedItem.setAttribute('value',id);
- }
-
- var label = _noteToTitle(_notesField.value);
- _notesMenu.selectedItem.label = label; //sets the individual item label
- _notesMenu.setAttribute('label', label); //sets the 'overall' label of the menu... not usually updated unless the item is reselected
- }
-
- function removeSelectedNote()
+ function removeNote(id)
{
- if(_notesField.value != "")
+ if(_itemBeingEdited.getNote(id) != "")
if(!confirm(Scholar.getString('pane.item.notes.delete.confirm')))
return;
- var id = _selectedNoteID();
if(id)
- {
_itemBeingEdited.removeNote(id);
- }
-
- var oldIndex = _notesMenu.selectedIndex;
- _notesMenu.removeItemAt(oldIndex);
- _notesMenu.selectedIndex = Math.max(oldIndex-1,0);
-
- if(_notesMenu.firstChild.childNodes.length == 0)
- {
- addNote();
- }
- else
- {
- onNoteSelected();
- _updateNoteCount();
- }
}
function addNote()
@@ -351,18 +325,6 @@ ScholarItemPane = new function()
window.open("chrome://scholar/content/note.xul?item="+_itemBeingEdited.getID(),'','chrome,resizable,centerscreen');
}
- function onNoteSelected()
- {
- var id = _selectedNoteID();
-
- Scholar.debug(id);
-
- if(id)
- _notesField.value = _itemBeingEdited.getNote(id);
- else
- _notesField.value = "";
- }
-
function _noteToTitle(text)
{
var MAX_LENGTH = 100;
@@ -390,11 +352,6 @@ ScholarItemPane = new function()
_notesLabel.value = Scholar.getString('pane.item.notes.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
}
-
- function _selectedNoteID()
- {
- return _notesMenu.selectedItem.getAttribute('value'); //for some reason, selectedItem.value is null sometimes.
- }
}
addEventListener("load", function(e) { ScholarItemPane.onLoad(e); }, false);
diff --git a/chrome/chromeFiles/content/scholar/itemPane.xul b/chrome/chromeFiles/content/scholar/itemPane.xul
@@ -36,6 +36,7 @@
<grid flex="1">
<columns>
<column flex="1"/>
+ <column/>
</columns>
<rows id="editpane-dynamic-notes" flex="1"/>
</grid>