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.
This commit is contained in:
parent
2dece39ad3
commit
0991ae230e
5 changed files with 47 additions and 23 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue