www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 0991ae230ebbaf2a4765376a1d7efc4fab6085c4
parent 2dece39ad39c3eed3e33358b7b8cac02298e00e6
Author: David Norton <david@nortoncrew.com>
Date:   Tue, 27 Jun 2006 22:47:17 +0000

Fixes #94, New independent notes do not appear in item view until clicking away from folder and back

Also fixes a lot of other issues regarding independant notes.

Diffstat:
Mchrome/chromeFiles/content/scholar/itemPane.js | 4++--
Mchrome/chromeFiles/content/scholar/itemTreeView.js | 23++++++++++++-----------
Mchrome/chromeFiles/content/scholar/note.js | 33++++++++++++++++++++++++---------
Mchrome/chromeFiles/content/scholar/overlay.js | 8+++++++-
Mchrome/chromeFiles/content/scholar/overlay.xul | 2++
5 files changed, 47 insertions(+), 23 deletions(-)

diff --git 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()+"&note="+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 @@ -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 @@ -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 @@ -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 @@ -70,6 +70,7 @@ <toolbarbutton id="tb-add" tooltiptext="&toolbar.newItem.label;" type="menu"> <menupopup/> </toolbarbutton> + <toolbarbutton label="New Note" oncommand="ScholarPane.openNoteWindow();"/> <spacer flex="1"/> <toolbarbutton id="tb-item-menu" type="menu" menu="scholar-itemmenu"/> <label value="&toolbar.search.label;" control="tb-search"/> @@ -145,6 +146,7 @@ <tabbox id="scholar-view-item" flex="1"/> <vbox id="scholar-view-note" flex="1" pack="center" align="center"> <label>Inline editing: coming soon</label> + <button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID'));"/> </vbox> </deck> </hbox>