www

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

commit 4757d21b20f481a043aa353d115a32439f16e57c
parent 40ef9f669d4c8f5dfe7e47f0861509abcfc0104c
Author: David Norton <david@nortoncrew.com>
Date:   Mon, 31 Jul 2006 16:58:14 +0000

Fixes #143, Scholar toolbar button to save current page as an independent file in the selected project.

Diffstat:
Mchrome/chromeFiles/content/scholar/itemPane.js | 20++++----------------
Mchrome/chromeFiles/content/scholar/overlay.js | 26++++++++++++++++++++++++++
Mchrome/chromeFiles/content/scholar/overlay.xul | 8++++++++
Mchrome/chromeFiles/skin/default/scholar/overlay.css | 5+++++
4 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js @@ -138,6 +138,7 @@ ScholarItemPane = new function() var label = document.createElement('label'); label.setAttribute('value',_noteToTitle(notes[i].getNote())); + label.setAttribute('flex','1'); //so that the long names will flex smaller label.setAttribute('crop','end'); var box = document.createElement('box'); @@ -177,6 +178,7 @@ ScholarItemPane = new function() var label = document.createElement('label'); label.setAttribute('value',files[i].getField('title')); + label.setAttribute('flex','1'); //so that the long names will flex smaller label.setAttribute('crop','end'); var box = document.createElement('box'); @@ -442,26 +444,12 @@ ScholarItemPane = new function() function addFileFromDialog(link) { - 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) - { - if(link) - Scholar.Files.linkFromFile(fp.file, _itemBeingEdited.getID()); - else - Scholar.Files.importFromFile(fp.file, _itemBeingEdited.getID()); - } + ScholarPane.addFileFromDialog(link, _itemBeingEdited.getID()); } function addFileFromPage(link) { - if(link) - Scholar.Files.linkFromDocument(window.content.document, _itemBeingEdited.getID()); - else - Scholar.Files.importFromDocument(window.content.document, _itemBeingEdited.getID()); + ScholarPane.addFileFromPage(link, _itemBeingEdited.getID()); } } diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js @@ -27,6 +27,8 @@ var ScholarPane = new function() this.buildItemContextMenu = buildItemContextMenu; this.openNoteWindow = openNoteWindow; this.newNote = newNote; + this.addFileFromDialog = addFileFromDialog; + this.addFileFromPage = addFileFromPage; /* * Called when the window is open @@ -346,6 +348,30 @@ var ScholarPane = new function() { window.open('chrome://scholar/content/note.xul?v=1'+(id ? '&id='+id : '')+(parent ? '&coll='+parent : ''),'','chrome,resizable,centerscreen'); } + + function addFileFromDialog(link, id) + { + 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) + { + if(link) + Scholar.Files.linkFromFile(fp.file, id); + else + Scholar.Files.importFromFile(fp.file, id); + } + } + + function addFileFromPage(link, id) + { + if(link) + Scholar.Files.linkFromDocument(window.content.document, id); + else + Scholar.Files.importFromDocument(window.content.document, id); + } } window.addEventListener("load", function(e) { ScholarPane.onLoad(e); }, false); diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul @@ -81,6 +81,14 @@ <toolbarbutton id="tb-add" tooltiptext="&toolbar.newItem.label;" type="menu"> <menupopup/> </toolbarbutton> + <toolbarbutton id="tb-file-add" type="menu" tooltiptext="New Standalone File"> + <menupopup> + <menuitem label="Add File..." oncommand="ScholarPane.addFileFromDialog();"/> + <menuitem label="Add Linked File..." oncommand="ScholarPane.addFileFromDialog(true);"/> + <menuitem label="Snapshot Current Page" oncommand="ScholarPane.addFileFromPage();"/> + <menuitem label="Link to Current Page" oncommand="ScholarPane.addFileFromPage(true);"/> + </menupopup> + </toolbarbutton> <toolbarbutton id="tb-note-add" tooltiptext="New Standalone Note" oncommand="ScholarPane.newNote();"/> <spacer flex="1"/> <label value="&toolbar.search.label;" control="tb-search"/> diff --git a/chrome/chromeFiles/skin/default/scholar/overlay.css b/chrome/chromeFiles/skin/default/scholar/overlay.css @@ -89,6 +89,11 @@ list-style-image: url('chrome://scholar/skin/toolbar-note-add.png'); } +#tb-file-add +{ + list-style-image: url('chrome://scholar/skin/item-files-add.png'); +} + #tb-item-files-add { list-style-image: url('chrome://scholar/skin/item-files-add.png');