diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js index 54b3306793..a72a924d32 100644 --- a/chrome/chromeFiles/content/scholar/itemPane.js +++ b/chrome/chromeFiles/content/scholar/itemPane.js @@ -122,7 +122,7 @@ ScholarItemPane = new function() label.setAttribute('crop','end'); box = document.createElement('box'); - box.setAttribute('onclick',"window.open('chrome://scholar/content/note.xul?item="+_itemBeingEdited.getID()+"¬e="+notes[i].getID()+"','','chrome,resizable,centerscreen');"); + box.setAttribute('onclick',"ScholarPane.openNoteWindow("+notes[i].getID()+");"); box.setAttribute('class','clicky'); box.appendChild(icon); box.appendChild(label); @@ -322,7 +322,7 @@ ScholarItemPane = new function() function addNote() { - window.open("chrome://scholar/content/note.xul?item="+_itemBeingEdited.getID(),'','chrome,resizable,centerscreen'); + ScholarPane.openNoteWindow(_itemBeingEdited.getID()); } function _noteToTitle(text) diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js index 870e4e3bad..24da03cd7b 100644 --- a/chrome/chromeFiles/content/scholar/itemTreeView.js +++ b/chrome/chromeFiles/content/scholar/itemTreeView.js @@ -51,7 +51,7 @@ Scholar.ItemTreeView.prototype.refresh = function() var newRows = this._itemGroup.getChildItems(); for(var i = 0; i < newRows.length; i++) if(newRows[i]) - this._showItem(new Scholar.ItemTreeView.TreeRow('item',newRows[i],0,false), i+1); //item ref, before row + this._showItem(new Scholar.ItemTreeView.TreeRow(newRows[i],0,false), i+1); //item ref, before row this._refreshHashMap(); } @@ -113,9 +113,9 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids) { var item = Scholar.Items.get(ids); - if((this._itemGroup.isLibrary() || item.inCollection(this._itemGroup.ref.getID())) && this._itemRowMap[ids] == null && !item.isNote()) + if((this._itemGroup.isLibrary() || item.inCollection(this._itemGroup.ref.getID())) && this._itemRowMap[ids] == null && (!item.isNote() || !item.getNoteSource())) { - this._showItem(new Scholar.ItemTreeView.TreeRow('item',item,0,false),this.rowCount); + this._showItem(new Scholar.ItemTreeView.TreeRow(item,0,false),this.rowCount); this._treebox.rowCountChanged(this.rowCount-1,1); madeChanges = true; @@ -262,7 +262,7 @@ Scholar.ItemTreeView.prototype.toggleOpenState = function(row) for(var i = 0; i < newRows.length; i++) { count++; - this._showItem(new Scholar.ItemTreeView.TreeRow('note',newRows[i],thisLevel+1,false), row+i+1); //item ref, before row + this._showItem(new Scholar.ItemTreeView.TreeRow(newRows[i],thisLevel+1,false), row+i+1); //item ref, before row } } @@ -596,9 +596,8 @@ Scholar.ItemTreeView.prototype.getRowProperties = function(row, prop) { } Scholar.ItemTreeView.prototype.getColumnProperties = function(col, prop) { } Scholar.ItemTreeView.prototype.getCellProperties = function(row, col, prop) { } -Scholar.ItemTreeView.TreeRow = function(type, ref, level, isOpen) +Scholar.ItemTreeView.TreeRow = function(ref, level, isOpen) { - this.type = type; //either 'item' or 'note' this.ref = ref; //the item/note associated with this this.level = level; this.isOpen = isOpen; @@ -614,11 +613,13 @@ Scholar.ItemTreeView.TreeRow.prototype.getField = function(field) if(this.isNote() && field == 'title') { var t = this.ref.getNote(); - var n = t.indexOf("\n"); - if(n > -1) - t = t.substring(0,n); - return t; - + if(t) + { + var n = t.indexOf("\n"); + if(n > -1) + t = t.substring(0,n); + return t; + } } else { diff --git a/chrome/chromeFiles/content/scholar/note.js b/chrome/chromeFiles/content/scholar/note.js index cc08d5316f..ab16b5c029 100644 --- a/chrome/chromeFiles/content/scholar/note.js +++ b/chrome/chromeFiles/content/scholar/note.js @@ -15,14 +15,26 @@ function onLoad() params[b[i].substr(0,mid)] = b[i].substr(mid+1); } - item = Scholar.Items.get(params['item']); - var noteID = params['note']; + var id = params['id']; - document.getElementById('info-label').appendChild(document.createTextNode(item.getField('title') + " by " + item.getField('firstCreator'))); - if(noteID) + if(id && id != '' && id != 'undefined') { - note = Scholar.Items.get(noteID); - _notesField.setAttribute('value',note.getNote()); + var ref = Scholar.Items.get(id); + if(ref.isNote()) + { + note = ref; + if(note.getNoteSource()) + item = Scholar.Items.get(note.getNoteSource()); + + _notesField.setAttribute('value',note.getNote()); + } + else + { + item = ref; + } + + if(item) + document.getElementById('info-label').appendChild(document.createTextNode(item.getField('title') + " by " + item.getField('firstCreator'))); } } @@ -33,13 +45,16 @@ function onUnload() function save() { - if(note) + if(note) //Update note { note.updateNote(_notesField.value); } - else + else //Create new note { - var noteID = Scholar.Notes.add(_notesField.value,item.getID()); + if(item) + var noteID = Scholar.Notes.add(_notesField.value,item.getID()); //attached to an item + else + var noteID = Scholar.Notes.add(_notesField.value); //independant note note = Scholar.Items.get(noteID); } } diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js index 2b35ff1eae..1aabe1a7cd 100644 --- a/chrome/chromeFiles/content/scholar/overlay.js +++ b/chrome/chromeFiles/content/scholar/overlay.js @@ -23,6 +23,7 @@ var ScholarPane = new function() this.getItemsView = getItemsView; this.buildCollectionContextMenu = buildCollectionContextMenu; this.buildItemContextMenu = buildItemContextMenu; + this.openNoteWindow = openNoteWindow; /* * Called when the window is open @@ -127,7 +128,7 @@ var ScholarPane = new function() if(item.isNote()) { - + document.getElementById('scholar-view-note').lastChild.setAttribute('noteID',item.ref.getID()); document.getElementById('item-pane').selectedIndex = 2; } else @@ -229,6 +230,11 @@ var ScholarPane = new function() else menu.childNodes[2].setAttribute('label', Scholar.getString('pane.items.menu.remove')); } + + function openNoteWindow(id) + { + window.open('chrome://scholar/content/note.xul?id='+id,'','chrome,resizable,centerscreen'); + } } window.addEventListener("load", function(e) { ScholarPane.onLoad(e); }, false); diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul index e25a1bef18..ff40a26d0e 100644 --- a/chrome/chromeFiles/content/scholar/overlay.xul +++ b/chrome/chromeFiles/content/scholar/overlay.xul @@ -70,6 +70,7 @@ +