closes #22, button in note pane for new note

closes #26, notes list in notes pane
closes #79, add icons for new object types
fixes #71, Metadata pane should be refreshed on a notify() event for the selected item
This commit is contained in:
David Norton 2006-06-26 12:58:22 +00:00
parent a33b119dff
commit fb9e803ab5
17 changed files with 83 additions and 41 deletions

View File

@ -3,8 +3,7 @@ ScholarItemPane = new function()
var _dynamicFields; var _dynamicFields;
var _creatorTypeMenu; var _creatorTypeMenu;
var _beforeRow; var _beforeRow;
var _notesMenu; var _notesList;
var _notesField;
var _notesLabel; var _notesLabel;
var _creatorCount; var _creatorCount;
@ -30,9 +29,8 @@ ScholarItemPane = new function()
_dynamicFields = document.getElementById('editpane-dynamic-fields'); _dynamicFields = document.getElementById('editpane-dynamic-fields');
_itemTypeMenu = document.getElementById('editpane-type-menu'); _itemTypeMenu = document.getElementById('editpane-type-menu');
_creatorTypeMenu = document.getElementById('creatorTypeMenu'); _creatorTypeMenu = document.getElementById('creatorTypeMenu');
_notesMenu = document.getElementById('scholar-notes-menu'); _notesList = document.getElementById('editpane-dynamic-notes');
_notesField = document.getElementById('scholar-notes-field'); _notesLabel = document.getElementById('editpane-notes-label');
_notesLabel = document.getElementById('scholar-notes-label');
var creatorTypes = Scholar.CreatorTypes.getTypes(); var creatorTypes = Scholar.CreatorTypes.getTypes();
for(var i = 0; i < creatorTypes.length; i++) for(var i = 0; i < creatorTypes.length; i++)
@ -56,10 +54,7 @@ ScholarItemPane = new function()
* Loads an item * Loads an item
*/ */
function viewItem(thisItem) function viewItem(thisItem)
{ {
if(_itemBeingEdited && thisItem.getID() == _itemBeingEdited.getID())
return;
if(document.commandDispatcher.focusedElement) if(document.commandDispatcher.focusedElement)
document.commandDispatcher.focusedElement.blur(); document.commandDispatcher.focusedElement.blur();
@ -112,19 +107,25 @@ ScholarItemPane = new function()
} }
//NOTES: //NOTES:
_notesMenu.removeAllItems(); while(_notesList.hasChildNodes())
_notesList.removeChild(_notesList.firstChild);
var notes = _itemBeingEdited.getNotes(); var notes = _itemBeingEdited.getNotes();
if(notes.length) if(notes.length)
{
for(var i = 0; i < notes.length; i++) for(var i = 0; i < notes.length; i++)
_notesMenu.appendItem(_noteToTitle(_itemBeingEdited.getNote(notes[i])),notes[i]); {
else var row = document.createElement('row');
addNote(); 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()+"&note="+notes[i]+"','','chrome,resizable,centerscreen');");
button.setAttribute('class','clicky')
row.appendChild(button);
_notesList.appendChild(row);
}
}
_updateNoteCount(); _updateNoteCount();
_notesMenu.selectedIndex = 0;
onNoteSelected();
} }
function changeTypeTo(id) function changeTypeTo(id)
@ -347,12 +348,7 @@ ScholarItemPane = new function()
function addNote() function addNote()
{ {
modifySelectedNote(); window.open("chrome://scholar/content/note.xul?item="+_itemBeingEdited.getID(),'','chrome,resizable,centerscreen');
_notesMenu.appendItem(Scholar.getString('pane.item.notes.untitled'),null);
_notesMenu.selectedIndex = _notesMenu.firstChild.childNodes.length-1;
onNoteSelected();
_updateNoteCount();
} }
function onNoteSelected() function onNoteSelected()
@ -390,7 +386,7 @@ ScholarItemPane = new function()
function _updateNoteCount() function _updateNoteCount()
{ {
var c = _notesMenu.firstChild.childNodes.length; var c = _notesList.childNodes.length;
_notesLabel.value = Scholar.getString('pane.item.notes.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":"; _notesLabel.value = Scholar.getString('pane.item.notes.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
} }

View File

@ -31,18 +31,14 @@
</grid> </grid>
</vbox> </vbox>
<vbox> <vbox>
<hbox align="center"> <button label="New Note" oncommand="ScholarItemPane.addNote();"/>
<label id="scholar-notes-label"/> <label id="editpane-notes-label"/>
<menulist flex="1" id="scholar-notes-menu" oncommand="ScholarItemPane.onNoteSelected();"> <grid flex="1">
<menupopup/> <columns>
</menulist> <column flex="1"/>
<label value="&scholar.minus;" class="clicky" onclick="ScholarItemPane.removeSelectedNote();"/> </columns>
<label value="&scholar.plus;" class="clicky" onclick="ScholarItemPane.addNote();"/> <rows id="editpane-dynamic-notes" flex="1"/>
</hbox> </grid>
<textbox id="scholar-notes-field"
type="timed" timeout="1000" oncommand="ScholarItemPane.modifySelectedNote();"
multiline="true" flex="1"
onblur="ScholarItemPane.modifySelectedNote();"/>
</vbox> </vbox>
<vbox align="center" pack="center"> <vbox align="center" pack="center">
<label value="Coming soon"/> <label value="Coming soon"/>

View File

@ -0,0 +1,33 @@
var item;
var noteID;
var note;
var _notesField;
function onLoad()
{
_notesField = document.getElementById('notes-box');
var params = new Array();
var b = document.location.href.substr(document.location.href.indexOf('?')+1).split('&');
for(var i = 0; i < b.length; i++)
{
var mid = b[i].indexOf('=');
params[b[i].substr(0,mid)] = b[i].substr(mid+1);
}
item = Scholar.Items.get(params['item']);
noteID = params['note'];
document.getElementById('info-label').setAttribute('value',item.getField('title'));
if(noteID)
_notesField.setAttribute('value',item.getNote(noteID));
}
function save()
{
if(noteID)
item.updateNote(noteID,_notesField.value);
else
noteID = item.addNote(_notesField.value);
}
addEventListener("load", function(e) { onLoad(e); }, false);

View File

@ -0,0 +1,18 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<window
id="scholar-note-window"
title="Edit Note"
orient="vertical"
width="400"
height="250"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="include.js"/>
<script src="note.js"/>
<label id="info-label"/>
<textbox id="notes-box" flex="1" multiline="true" type="timed" timeout="1000" oncommand="save();"/>
</window>

View File

@ -120,11 +120,6 @@ vbox #scholar-pane
background: #666666; background: #666666;
} }
textbox[multiline="true"][type="timed"]
{
-moz-binding: url('chrome://scholar/content/customControls.xml#timed-textarea');
}
#scholar-splitter #scholar-splitter
{ {
border-top: none; border-top: none;

View File

@ -0,0 +1,4 @@
textbox[multiline="true"][type="timed"]
{
-moz-binding: url('chrome://scholar/content/customControls.xml#timed-textarea');
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B