commit 3a3b6ab70dfdb5254c17d44318d70e3cd71f9578
parent 20bad3609d14bb7c7f05a55706cd9398a409f298
Author: David Norton <david@nortoncrew.com>
Date: Wed, 28 Jun 2006 18:30:29 +0000
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.
Diffstat:
6 files changed, 93 insertions(+), 36 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/customControls.xml b/chrome/chromeFiles/content/scholar/customControls.xml
@@ -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>
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/scholar/note.js b/chrome/chromeFiles/content/scholar/note.js
@@ -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);
diff --git a/chrome/chromeFiles/content/scholar/note.xul b/chrome/chromeFiles/content/scholar/note.xul
@@ -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>
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js
@@ -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;
}
diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul
@@ -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>
diff --git a/chrome/chromeFiles/skin/default/scholar/scholar.css b/chrome/chromeFiles/skin/default/scholar/scholar.css
@@ -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;