- Use note title for popup note window title

- Only allow a note to be opened once -- opening one that's already opened just brings note to front
This commit is contained in:
Dan Stillman 2007-10-05 17:59:48 +00:00
parent 92562ab412
commit bc9097944e
3 changed files with 38 additions and 19 deletions

View File

@ -1540,7 +1540,7 @@ var ZoteroItemPane = new function()
function addNote()
{
ZoteroPane.openNoteWindow(_itemBeingEdited.getID());
ZoteroPane.openNoteWindow(null, null, _itemBeingEdited.getID());
}
function _noteToTitle(text)

View File

@ -39,21 +39,18 @@ function onLoad()
params[b[i].substr(0,mid)] = b[i].substr(mid+1);
}
var id = params['id'];
var itemID = params['id'];
var collectionID = params['coll'];
var parentItemID = params['p'];
if(id && id != '' && id != 'undefined')
{
var ref = Zotero.Items.get(id);
if(ref.isNote())
{
noteEditor.note = ref;
document.title = Zotero.getString('noteEditor.editNote');
}
else
{
noteEditor.item = ref;
}
if (itemID) {
var ref = Zotero.Items.get(itemID);
noteEditor.note = ref;
document.title = ref.getNoteTitle();
}
else if (parentItemID) {
var ref = Zotero.Items.get(parentItemID);
noteEditor.item = ref;
}
else
{
@ -77,6 +74,9 @@ var NotifyCallback = {
// DEBUG: why does this reset without checking the modified ids?
if (noteEditor.note){
noteEditor.note = noteEditor.note;
document.title = noteEditor.note.getNoteTitle();
// Update the window name (used for focusing) in case this is a new note
window.name = 'zotero-note-' + noteEditor.note.getID();
}
}
}

View File

@ -1785,14 +1785,33 @@ var ZoteroPane = new function()
return false;
}
function openNoteWindow(id, parent)
function openNoteWindow(itemID, col, parentItemID)
{
if (id) {
var item = Zotero.Items.get(id)
var name = null;
if (itemID) {
// Create a name for this window so we can focus it later
//
// Collection is only used on new notes, so we don't need to
// include it in the name
name = 'zotero-note-' + itemID;
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var e = wm.getEnumerator('');
while (e.hasMoreElements()) {
var w = e.getNext();
if (w.name == name) {
w.focus();
return;
}
}
}
window.open('chrome://zotero/content/note.xul?v=1'
+ (id ? '&id=' + id : '') + (parent ? '&coll=' + parent : ''),
'', 'chrome,resizable,centerscreen');
+ (itemID ? '&id=' + itemID : '') + (col ? '&coll=' + col : '')
+ (parentItemID ? '&p=' + parentItemID : ''),
name, 'chrome,resizable,centerscreen');
}