From 8ff6c48001a617ac08b6fd594182d546cc113ab9 Mon Sep 17 00:00:00 2001 From: David Norton Date: Fri, 16 Jun 2006 14:39:18 +0000 Subject: [PATCH] [interface] Custom textbox binding: multiline and timed together. [interface] Multiple notes: works like a charm --- .../content/scholar/customControls.xml | 44 +++++++++++++++++ .../chromeFiles/content/scholar/itemPane.js | 48 ++++++++++++++----- .../chromeFiles/content/scholar/itemPane.xul | 4 +- .../skin/default/scholar/overlay.css | 5 ++ 4 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 chrome/chromeFiles/content/scholar/customControls.xml diff --git a/chrome/chromeFiles/content/scholar/customControls.xml b/chrome/chromeFiles/content/scholar/customControls.xml new file mode 100644 index 0000000000..76274675ed --- /dev/null +++ b/chrome/chromeFiles/content/scholar/customControls.xml @@ -0,0 +1,44 @@ + + + + + null + + + + return this.inputField.value; + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js index ccb9642290..6657c0cfa6 100644 --- a/chrome/chromeFiles/content/scholar/itemPane.js +++ b/chrome/chromeFiles/content/scholar/itemPane.js @@ -107,6 +107,8 @@ ScholarItemPane = new function() _updateNoteCount(); _notesMenu.selectedIndex = 0; + + onNoteSelected(); } function addDynamicRow(label, value, beforeElement) @@ -269,8 +271,8 @@ ScholarItemPane = new function() if(_notesMenu.selectedIndex == -1) return; - var id = _notesMenu.selectedItem.value; - if(id) + var id = _selectedNoteID(); + if(id && id != "undefined") { _itemBeingEdited.updateNote(id,_notesField.value); } @@ -279,24 +281,33 @@ ScholarItemPane = new function() id = _itemBeingEdited.addNote(_notesField.value); _notesMenu.selectedItem.value = id; } - var label = _notesField.value; - _notesMenu.selectedItem.label = _noteToTitle(_notesField.value); + var label = _noteToTitle(_notesField.value); + _notesMenu.selectedItem.setAttribute('label', label); + _notesMenu.setAttribute('label', label); } function removeSelectedNote() { - var id = _notesMenu.selectedItem.value; - if(id) + var id = _selectedNoteID(); + if(id && id != "undefined") { _itemBeingEdited.removeNote(id); } - _notesMenu.removeitemAt(_notesMenu.selectedIndex); + + var oldIndex = _notesMenu.selectedIndex; + _notesMenu.removeItemAt(oldIndex); + _notesMenu.selectedIndex = Math.max(oldIndex-1,0); if(_notesMenu.firstChild.childNodes.length == 0) + { addNote(); - - _updateNoteCount(); + } + else + { + onNoteSelected(); + _updateNoteCount(); + } } function addNote() @@ -305,13 +316,17 @@ ScholarItemPane = new function() _notesMenu.appendItem('Untitled Note'); _notesMenu.selectedIndex = _notesMenu.firstChild.childNodes.length-1; + onNoteSelected(); _updateNoteCount(); } function onNoteSelected() { - var id = _notesMenu.selectedItem.value; - if(id) + var id = _selectedNoteID(); + + Scholar.debug(id); + + if(id && id != "undefined") _notesField.value = _itemBeingEdited.getNote(id); else _notesField.value = ""; @@ -319,9 +334,11 @@ ScholarItemPane = new function() function _noteToTitle(text) { - var t = text.substring(0, 30); + var MAX_LENGTH = 100; + + var t = text.substring(0, MAX_LENGTH); var ln = t.indexOf("\n"); - if (ln>-1 && ln<30) + if (ln>-1 && ln