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>
|
</handler>
|
||||||
</handlers>
|
</handlers>
|
||||||
</binding>
|
</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>
|
</bindings>
|
|
@ -1,11 +1,9 @@
|
||||||
var item;
|
var noteEditor;
|
||||||
var note;
|
|
||||||
var _notesField;
|
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
{
|
{
|
||||||
_notesField = document.getElementById('notes-box');
|
noteEditor = document.getElementById('note-editor');
|
||||||
_notesField.focus();
|
noteEditor.focus();
|
||||||
|
|
||||||
var params = new Array();
|
var params = new Array();
|
||||||
var b = document.location.href.substr(document.location.href.indexOf('?')+1).split('&');
|
var b = document.location.href.substr(document.location.href.indexOf('?')+1).split('&');
|
||||||
|
@ -22,41 +20,25 @@ function onLoad()
|
||||||
var ref = Scholar.Items.get(id);
|
var ref = Scholar.Items.get(id);
|
||||||
if(ref.isNote())
|
if(ref.isNote())
|
||||||
{
|
{
|
||||||
note = ref;
|
noteEditor.note = ref;
|
||||||
if(note.getNoteSource())
|
window.title = "Edit Note";
|
||||||
item = Scholar.Items.get(note.getNoteSource());
|
|
||||||
|
|
||||||
_notesField.setAttribute('value',note.getNote());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item = ref;
|
noteEditor.item = ref;
|
||||||
|
window.title = "Add Note";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(item)
|
else
|
||||||
document.getElementById('info-label').appendChild(document.createTextNode(item.getField('title') + " by " + item.getField('firstCreator')));
|
{
|
||||||
|
window.title = "Edit Note";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUnload()
|
function onUnload()
|
||||||
{
|
{
|
||||||
save();
|
if(noteEditor && noteEditor.value)
|
||||||
}
|
noteEditor.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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addEventListener("load", function(e) { onLoad(e); }, false);
|
addEventListener("load", function(e) { onLoad(e); }, false);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
<window
|
<window
|
||||||
id="scholar-note-window"
|
id="scholar-note-window"
|
||||||
title="Edit Note"
|
|
||||||
orient="vertical"
|
orient="vertical"
|
||||||
width="400"
|
width="400"
|
||||||
height="250"
|
height="250"
|
||||||
|
@ -18,6 +17,5 @@
|
||||||
</keyset>
|
</keyset>
|
||||||
<command id="cmd_close" oncommand="window.close();"/>
|
<command id="cmd_close" oncommand="window.close();"/>
|
||||||
|
|
||||||
<label id="info-label"/>
|
<noteeditor id="note-editor" flex="1"/>
|
||||||
<textbox id="notes-box" flex="1" multiline="true" type="timed" timeout="1000" oncommand="save();"/>
|
|
||||||
</window>
|
</window>
|
|
@ -139,6 +139,9 @@ var ScholarPane = new function()
|
||||||
|
|
||||||
if(item.isNote())
|
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('scholar-view-note').lastChild.setAttribute('noteID',item.ref.getID());
|
||||||
document.getElementById('item-pane').selectedIndex = 2;
|
document.getElementById('item-pane').selectedIndex = 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,8 +144,8 @@
|
||||||
<deck id="item-pane" selectedIndex="0">
|
<deck id="item-pane" selectedIndex="0">
|
||||||
<box pack="center" align="center"><label id="scholar-view-selected-label"/></box>
|
<box pack="center" align="center"><label id="scholar-view-selected-label"/></box>
|
||||||
<tabbox id="scholar-view-item" flex="1"/>
|
<tabbox id="scholar-view-item" flex="1"/>
|
||||||
<vbox id="scholar-view-note" flex="1" pack="center" align="center">
|
<vbox id="scholar-view-note" flex="1">
|
||||||
<label>Inline editing: coming soon</label>
|
<noteeditor id="scholar-note-editor" flex="1"/>
|
||||||
<button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID'));"/>
|
<button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID'));"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
</deck>
|
</deck>
|
||||||
|
|
|
@ -3,6 +3,11 @@ textbox[multiline="true"][type="timed"]
|
||||||
-moz-binding: url('chrome://scholar/content/customControls.xml#timed-textarea');
|
-moz-binding: url('chrome://scholar/content/customControls.xml#timed-textarea');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
noteeditor
|
||||||
|
{
|
||||||
|
-moz-binding: url('chrome://scholar/content/customControls.xml#note-editor');
|
||||||
|
}
|
||||||
|
|
||||||
#scholar-progress-box
|
#scholar-progress-box
|
||||||
{
|
{
|
||||||
border: 2px solid #7a0000;
|
border: 2px solid #7a0000;
|
||||||
|
|
Loading…
Reference in a new issue