www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 49d1eec9e84f129593c000de4932b9a15dd87799
parent 441696767a3d6a191b2000f8653e997d27369d2a
Author: David Norton <david@nortoncrew.com>
Date:   Thu, 27 Jul 2006 18:08:09 +0000

Closes #127, Display files under files tab
Closes #128, Display files as children of item in items list

Fixes #132, On Full-screen mode, browser content disappears but Scholar content does not stretch.
Fixes #133, When Scholar on top, pane automatically resizes depending on item info height.

Diffstat:
Mchrome/chromeFiles/content/scholar/bindings/noteeditor.xml | 4++--
Mchrome/chromeFiles/content/scholar/itemPane.js | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Mchrome/chromeFiles/content/scholar/itemPane.xul | 15+++++++++++++--
Mchrome/chromeFiles/content/scholar/itemTreeView.js | 50+++++++++++++++++++++++++++++++++++++++++---------
Mchrome/chromeFiles/content/scholar/overlay.js | 10+++++++---
Mchrome/chromeFiles/content/scholar/overlay.xul | 8++++++--
Mchrome/chromeFiles/locale/en-US/scholar/scholar.properties | 5++++-
Achrome/chromeFiles/skin/default/scholar/treeitem-file.png | 0
8 files changed, 146 insertions(+), 25 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/bindings/noteeditor.xml b/chrome/chromeFiles/content/scholar/bindings/noteeditor.xml @@ -25,8 +25,8 @@ <![CDATA[ this.noteRef = val; - if(this.note.getNoteSource()) - this.item = Scholar.Items.get(this.note.getNoteSource()); + if(this.note.getSource()) + this.item = Scholar.Items.get(this.note.getSource()); this.id('noteField').setAttribute('value',this.note.getNote()); this.id('links').item = this.note; diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js @@ -25,6 +25,9 @@ ScholarItemPane = new function() this.modifyCreator = modifyCreator; this.removeNote = removeNote; this.addNote = addNote; + this.removeFile = removeFile; + this.addFileFromDialog = addFileFromDialog; + this.addFileFromPage = addFileFromPage; function onLoad() { @@ -34,6 +37,8 @@ ScholarItemPane = new function() _creatorTypeMenu = document.getElementById('creatorTypeMenu'); _notesList = document.getElementById('editpane-dynamic-notes'); _notesLabel = document.getElementById('editpane-notes-label'); + _filesList = document.getElementById('editpane-dynamic-files'); + _filesLabel = document.getElementById('editpane-files-label'); _tagsBox = document.getElementById('editpane-tags'); _relatedBox = document.getElementById('editpane-related'); @@ -50,7 +55,7 @@ ScholarItemPane = new function() var itemTypes = Scholar.ItemTypes.getTypes(); for(var i = 0; i<itemTypes.length; i++) - if(itemTypes[i]['id'] != 1) + if(itemTypes[i]['name'] != 'note' && itemTypes[i]['name'] != 'file') _itemTypeMenu.appendItem(Scholar.getString("itemTypes."+itemTypes[i]['name']),itemTypes[i]['id']); return true; @@ -76,7 +81,6 @@ ScholarItemPane = new function() if(index == 0) { - Scholar.debug('loading FIELDS'); while(_dynamicFields.hasChildNodes()) _dynamicFields.removeChild(_dynamicFields.firstChild); @@ -120,7 +124,6 @@ ScholarItemPane = new function() } else if(index == 1) { - Scholar.debug('loading NOTES'); //NOTES: while(_notesList.hasChildNodes()) _notesList.removeChild(_notesList.firstChild); @@ -160,18 +163,51 @@ ScholarItemPane = new function() } else if(index == 2) { - Scholar.debug('loading FILES'); //FILES + while(_filesList.hasChildNodes()) + _filesList.removeChild(_filesList.firstChild); + + var files = Scholar.Items.get(_itemBeingEdited.getFiles()); + if(files.length) + { + for(var i = 0; i < files.length; i++) + { + var icon = document.createElement('image'); + icon.setAttribute('src','chrome://scholar/skin/treeitem-file.png'); + + var label = document.createElement('label'); + label.setAttribute('value',files[i].getField('title')); + label.setAttribute('crop','end'); + + var box = document.createElement('box'); +// box.setAttribute('onclick',"ScholarPane.openNoteWindow("+files[i].getID()+");"); + box.setAttribute('class','clicky'); + box.appendChild(icon); + box.appendChild(label); + + var removeButton = document.createElement('label'); + removeButton.setAttribute("value","-"); + removeButton.setAttribute("class","clicky"); + removeButton.setAttribute("onclick","ScholarItemPane.removeFile("+files[i].getID()+")"); + + var row = document.createElement('row'); + row.appendChild(box); + row.appendChild(removeButton); + + _filesList.appendChild(row); + } + } + + _updateFileCount(); + } else if(index == 3) { - Scholar.debug('loading TAGS'); //TAGS: _tagsBox.item = _itemBeingEdited; } else if(index == 4) { - Scholar.debug('loading RELATED'); //RELATED _relatedBox.item = _itemBeingEdited; } @@ -388,6 +424,37 @@ ScholarItemPane = new function() _notesLabel.value = Scholar.getString('pane.item.notes.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":"; } + + function _updateFileCount() + { + var c = _filesList.childNodes.length; + + _filesLabel.value = Scholar.getString('pane.item.files.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":"; + } + + function removeFile(id) + { + var file = Scholar.Items.get(id); + if(file) + if(confirm(Scholar.getString('pane.item.files.delete.confirm'))) + file.erase(); + } + + function addFileFromDialog() + { + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"] + .createInstance(nsIFilePicker); + fp.init(window, "Select a File", nsIFilePicker.modeOpen); + + if(fp.show() == nsIFilePicker.returnOK) + Scholar.Files.importFromFile(fp.file, _itemBeingEdited.getID()); + } + + function addFileFromPage() + { + Scholar.Files.importFromDocument(window.document, _itemBeingEdited.getID()); + } } addEventListener("load", function(e) { ScholarItemPane.onLoad(e); }, false); diff --git a/chrome/chromeFiles/content/scholar/itemPane.xul b/chrome/chromeFiles/content/scholar/itemPane.xul @@ -34,8 +34,19 @@ <rows id="editpane-dynamic-notes" flex="1"/> </grid> </vbox> - <vbox align="center" pack="center"> - <label value="Coming soon"/> + <vbox flex="1"> + <hbox align="center"> + <label id="editpane-files-label"/> + <button label="Add File..." oncommand="ScholarItemPane.addFileFromDialog();"/> + <button label="Save Page" oncommand="ScholarItemPane.addFileFromPage();"/> + </hbox> + <grid flex="1"> + <columns> + <column flex="1"/> + <column/> + </columns> + <rows id="editpane-dynamic-files" flex="1"/> + </grid> </vbox> <tagsbox id="editpane-tags" flex="1"/> <seealsobox id="editpane-related" flex="1"/> diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js @@ -116,7 +116,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() || !item.getNoteSource())) + if((this._itemGroup.isLibrary() || item.inCollection(this._itemGroup.ref.getID())) //if the item belongs in this collection + && this._itemRowMap[ids] == null //if we haven't already added it to our hash map + && (item.isRegularItem() || !item.getSource())) //if it's stand-alone { this._showItem(new Scholar.ItemTreeView.TreeRow(item,0,false),this.rowCount); this._treebox.rowCountChanged(this.rowCount-1,1); @@ -205,7 +207,7 @@ Scholar.ItemTreeView.prototype.getImageSrc = function(row, col) Scholar.ItemTreeView.prototype.isContainer = function(row) { - return !this._getItemAtRow(row).isNote(); + return this._getItemAtRow(row).isRegularItem(); } Scholar.ItemTreeView.prototype.isContainerOpen = function(row) @@ -215,7 +217,7 @@ Scholar.ItemTreeView.prototype.isContainerOpen = function(row) Scholar.ItemTreeView.prototype.isContainerEmpty = function(row) { - return (this._getItemAtRow(row).numNotes() == 0); + return (this._getItemAtRow(row).numNotes() == 0 && this._getItemAtRow(row).numFiles() == 0); } Scholar.ItemTreeView.prototype.getLevel = function(row) @@ -260,13 +262,25 @@ Scholar.ItemTreeView.prototype.toggleOpenState = function(row) else { var item = this._getItemAtRow(row).ref; - var newRows = Scholar.Items.get(item.getNotes()); //Get children + //Get children + var files = item.getFiles(); + var notes = item.getNotes(); + + var newRows; + if(files && notes) + newRows = files.concat(notes); + else if(files) + newRows = files; + else if(notes) + newRows = notes; + + newRows = Scholar.Items.get(newRows); for(var i = 0; i < newRows.length; i++) { count++; this._showItem(new Scholar.ItemTreeView.TreeRow(newRows[i],thisLevel+1,false), row+i+1); //item ref, before row - } + } } this._treebox.beginUpdateBatch(); @@ -430,7 +444,7 @@ Scholar.ItemTreeView.prototype.deleteSelection = function() this._treebox.beginUpdateBatch(); for (var i=0; i<items.length; i++) { - if(this._itemGroup.isLibrary() || items[i].isNote()) //erase item from DB + if(this._itemGroup.isLibrary() || !items[i].isRegularItem()) //erase item from DB items[i].ref.erase(); else if(this._itemGroup.isCollection()) this._itemGroup.ref.removeItem(items[i].ref.getID()); @@ -601,7 +615,7 @@ Scholar.ItemTreeView.prototype.getCellProperties = function(row, col, prop) { } Scholar.ItemTreeView.TreeRow = function(ref, level, isOpen) { - this.ref = ref; //the item/note associated with this + this.ref = ref; //the item associated with this this.level = level; this.isOpen = isOpen; } @@ -611,6 +625,16 @@ Scholar.ItemTreeView.TreeRow.prototype.isNote = function() return this.ref.isNote(); } +Scholar.ItemTreeView.TreeRow.prototype.isFile = function() +{ + return this.ref.isFile(); +} + +Scholar.ItemTreeView.TreeRow.prototype.isRegularItem = function() +{ + return this.ref.isRegularItem(); +} + Scholar.ItemTreeView.TreeRow.prototype.getField = function(field) { if(this.isNote() && field == 'title') @@ -638,8 +662,16 @@ Scholar.ItemTreeView.TreeRow.prototype.getType = function() Scholar.ItemTreeView.TreeRow.prototype.numNotes = function() { - if(this.isNote()) + if(this.isRegularItem()) + return this.ref.numNotes(); + else return 0; +} + +Scholar.ItemTreeView.TreeRow.prototype.numFiles = function() +{ + if(this.isRegularItem()) + return this.ref.numFiles(); else - return this.ref.numNotes(); + return 0; } \ No newline at end of file diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js @@ -44,6 +44,7 @@ var ScholarPane = new function() newPane.setAttribute('id','scholar-pane'); newPane.setAttribute('collapsed',true); newPane.setAttribute('flex','1'); + newPane.height = oldPane.height; while(oldPane.hasChildNodes()) newPane.appendChild(oldPane.firstChild); appContent.removeChild(oldPane); @@ -168,19 +169,22 @@ var ScholarPane = new function() noteEditor.note = item.ref; document.getElementById('scholar-view-note').lastChild.setAttribute('noteID',item.ref.getID()); document.getElementById('item-pane').selectedIndex = 2; - document.getElementById('scholar-view-tabs').setAttribute('hidden',true); + } + else if(item.isFile()) + { + document.getElementById('scholar-file-label').setAttribute('value',item.getField('title')); + document.getElementById('scholar-file-links').item = item.ref; + document.getElementById('item-pane').selectedIndex = 3; } else { ScholarItemPane.viewItem(item.ref); document.getElementById('item-pane').selectedIndex = 1; - document.getElementById('scholar-view-tabs').setAttribute('hidden',false); } } else { document.getElementById('item-pane').selectedIndex = 0; - document.getElementById('scholar-view-tabs').setAttribute('hidden',true); var label = document.getElementById('scholar-view-selected-label'); diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul @@ -27,7 +27,7 @@ <vbox id="appcontent"> <!-- Changes to attributes of scholar-splitter and scholar-pane must be mirrored on overlay.js's onLoad() function --> <splitter id="scholar-splitter" resizebefore="closest" resizeafter="closest" collapsed="true"/> - <hbox id="scholar-pane" persist="height" collapsed="true"> + <hbox id="scholar-pane" persist="height" collapsed="true" flex="1"> <popupset> <popup id="scholar-collectionmenu" onpopupshowing="ScholarPane.buildCollectionContextMenu();"> <menuitem label="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/> @@ -166,7 +166,7 @@ <tab label="&tabs.related.label;"/> </tabs> </caption> - <deck id="item-pane" selectedIndex="0" flex="1"> + <deck id="item-pane" selectedIndex="0" flex="1" onselect="document.getElementById('scholar-view-tabs').setAttribute('hidden',(this.selectedIndex != 1));"> <box pack="center" align="center"> <label id="scholar-view-selected-label"/> </box> @@ -175,6 +175,10 @@ <noteeditor id="scholar-note-editor" flex="1"/> <button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID'));"/> </vbox> + <vbox id="scholar-view-file" flex="1"> + <label id="scholar-file-label"/> + <linksbox id="scholar-file-links" flex="1"/> + </vbox> </deck> </groupbox> </vbox> diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.properties b/chrome/chromeFiles/locale/en-US/scholar/scholar.properties @@ -18,9 +18,12 @@ pane.item.selected.multiple = %1 items selected pane.item.changeType = Are you sure you want to change the item type? Certain fields may be lost. pane.item.notes.untitled = Untitled Note -pane.item.notes.delete.confirm = Are you sure you want to delete the selected note? +pane.item.notes.delete.confirm = Are you sure you want to delete this note? pane.item.notes.count.singular = %1 note pane.item.notes.count.plural = %1 notes +pane.item.files.delete.confirm = Are you sure you want to delete this file? +pane.item.files.count.singular = %1 file +pane.item.files.count.plural = %1 files itemFields.title = Title itemFields.dateAdded = Date Added diff --git a/chrome/chromeFiles/skin/default/scholar/treeitem-file.png b/chrome/chromeFiles/skin/default/scholar/treeitem-file.png Binary files differ.