Fixes #30, clicking on note in the hierarchical view shows contents of the note in the right panel.
- Generally, restructured the way that editing notes works: there is now a <noteeditor> control.
This commit is contained in:
parent
20bad3609d
commit
3a3b6ab70d
6 changed files with 93 additions and 36 deletions
|
@ -41,4 +41,73 @@
|
|||
</handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
<binding id="note-editor">
|
||||
<implementation>
|
||||
<field name="itemRef"/>
|
||||
<property name="item" onget="return this.itemRef;">
|
||||
<setter>
|
||||
<![CDATA[
|
||||
this.itemRef = val;
|
||||
|
||||
var citeLabel = document.getAnonymousNodes(this)[0].childNodes[0];
|
||||
if(citeLabel.firstChild)
|
||||
citeLabel.removeChild(citeLabel.firstChild);
|
||||
|
||||
if(this.item)
|
||||
citeLabel.appendChild(document.createTextNode(this.item.getField('title')));
|
||||
]]>
|
||||
</setter>
|
||||
</property>
|
||||
<field name="noteRef"/>
|
||||
<property name="note" onget="return this.noteRef;">
|
||||
<setter>
|
||||
<![CDATA[
|
||||
this.noteRef = val;
|
||||
|
||||
if(this.note.getNoteSource())
|
||||
this.item = Scholar.Items.get(this.note.getNoteSource());
|
||||
|
||||
document.getAnonymousNodes(this)[0].childNodes[1].setAttribute('value',this.note.getNote());
|
||||
]]>
|
||||
</setter>
|
||||
</property>
|
||||
<property name="value" onget="return document.getAnonymousNodes(this)[0].childNodes[1].value;" onset="document.getAnonymousNodes(this)[0].childNodes[1].value = val;"/>
|
||||
<method name="save">
|
||||
<body>
|
||||
<![CDATA[
|
||||
var noteField = document.getAnonymousNodes(this)[0].childNodes[1];
|
||||
if(this.note) //Update note
|
||||
{
|
||||
this.note.updateNote(noteField.value);
|
||||
}
|
||||
else //Create new note
|
||||
{
|
||||
if(this.item)
|
||||
var noteID = Scholar.Notes.add(noteField.value,this.item.getID()); //attached to an item
|
||||
else
|
||||
var noteID = Scholar.Notes.add(noteField.value); //independant note
|
||||
this.note = Scholar.Items.get(noteID);
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
<method name="focus">
|
||||
<body>
|
||||
<![CDATA[
|
||||
document.getAnonymousNodes(this)[0].childNodes[1].focus();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
<handlers>
|
||||
</handlers>
|
||||
<content>
|
||||
<xul:vbox xbl:inherits="flex">
|
||||
<xul:label/>
|
||||
<xul:textbox multiline="true" type="timed" timeout="1000" flex="1" oncommand="this.parentNode.parentNode.save();"/>
|
||||
<xul:label value="See also: (coming soon)"/>
|
||||
<xul:label value="Tags: (coming soon)"/>
|
||||
</xul:vbox>
|
||||
</content>
|
||||
</binding>
|
||||
</bindings>
|
|
@ -1,11 +1,9 @@
|
|||
var item;
|
||||
var note;
|
||||
var _notesField;
|
||||
var noteEditor;
|
||||
|
||||
function onLoad()
|
||||
{
|
||||
_notesField = document.getElementById('notes-box');
|
||||
_notesField.focus();
|
||||
noteEditor = document.getElementById('note-editor');
|
||||
noteEditor.focus();
|
||||
|
||||
var params = new Array();
|
||||
var b = document.location.href.substr(document.location.href.indexOf('?')+1).split('&');
|
||||
|
@ -22,41 +20,25 @@ function onLoad()
|
|||
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());
|
||||
noteEditor.note = ref;
|
||||
window.title = "Edit Note";
|
||||
}
|
||||
else
|
||||
{
|
||||
item = ref;
|
||||
noteEditor.item = ref;
|
||||
window.title = "Add Note";
|
||||
}
|
||||
|
||||
if(item)
|
||||
document.getElementById('info-label').appendChild(document.createTextNode(item.getField('title') + " by " + item.getField('firstCreator')));
|
||||
}
|
||||
else
|
||||
{
|
||||
window.title = "Edit Note";
|
||||
}
|
||||
}
|
||||
|
||||
function onUnload()
|
||||
{
|
||||
save();
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
if(note) //Update note
|
||||
{
|
||||
note.updateNote(_notesField.value);
|
||||
}
|
||||
else //Create new note
|
||||
{
|
||||
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);
|
||||
}
|
||||
if(noteEditor && noteEditor.value)
|
||||
noteEditor.save();
|
||||
}
|
||||
|
||||
addEventListener("load", function(e) { onLoad(e); }, false);
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
<window
|
||||
id="scholar-note-window"
|
||||
title="Edit Note"
|
||||
orient="vertical"
|
||||
width="400"
|
||||
height="250"
|
||||
|
@ -18,6 +17,5 @@
|
|||
</keyset>
|
||||
<command id="cmd_close" oncommand="window.close();"/>
|
||||
|
||||
<label id="info-label"/>
|
||||
<textbox id="notes-box" flex="1" multiline="true" type="timed" timeout="1000" oncommand="save();"/>
|
||||
<noteeditor id="note-editor" flex="1"/>
|
||||
</window>
|
|
@ -139,6 +139,9 @@ var ScholarPane = new function()
|
|||
|
||||
if(item.isNote())
|
||||
{
|
||||
var noteEditor = document.getElementById('scholar-note-editor');
|
||||
noteEditor.item = null;
|
||||
noteEditor.note = item.ref;
|
||||
document.getElementById('scholar-view-note').lastChild.setAttribute('noteID',item.ref.getID());
|
||||
document.getElementById('item-pane').selectedIndex = 2;
|
||||
}
|
||||
|
|
|
@ -144,8 +144,8 @@
|
|||
<deck id="item-pane" selectedIndex="0">
|
||||
<box pack="center" align="center"><label id="scholar-view-selected-label"/></box>
|
||||
<tabbox id="scholar-view-item" flex="1"/>
|
||||
<vbox id="scholar-view-note" flex="1" pack="center" align="center">
|
||||
<label>Inline editing: coming soon</label>
|
||||
<vbox id="scholar-view-note" flex="1">
|
||||
<noteeditor id="scholar-note-editor" flex="1"/>
|
||||
<button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID'));"/>
|
||||
</vbox>
|
||||
</deck>
|
||||
|
|
|
@ -3,6 +3,11 @@ textbox[multiline="true"][type="timed"]
|
|||
-moz-binding: url('chrome://scholar/content/customControls.xml#timed-textarea');
|
||||
}
|
||||
|
||||
noteeditor
|
||||
{
|
||||
-moz-binding: url('chrome://scholar/content/customControls.xml#note-editor');
|
||||
}
|
||||
|
||||
#scholar-progress-box
|
||||
{
|
||||
border: 2px solid #7a0000;
|
||||
|
|
Loading…
Reference in a new issue