2006-08-02 16:49:19 +00:00
|
|
|
/*
|
|
|
|
Scholar
|
|
|
|
Copyright (C) 2006 Center for History and New Media, George Mason University, Fairfax, VA
|
|
|
|
http://chnm.gmu.edu/
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2006-06-02 15:27:52 +00:00
|
|
|
/*
|
|
|
|
* This object contains the various functions for the interface
|
|
|
|
*/
|
2006-05-30 22:06:33 +00:00
|
|
|
var ScholarPane = new function()
|
|
|
|
{
|
2006-06-05 18:01:53 +00:00
|
|
|
var collectionsView;
|
2006-05-30 22:06:33 +00:00
|
|
|
var itemsView;
|
|
|
|
|
2006-06-02 15:27:52 +00:00
|
|
|
//Privileged methods
|
|
|
|
this.onLoad = onLoad;
|
|
|
|
this.onUnload = onUnload;
|
|
|
|
this.toggleDisplay = toggleDisplay;
|
2006-07-05 16:19:26 +00:00
|
|
|
this.fullScreen = fullScreen;
|
2006-05-30 22:06:33 +00:00
|
|
|
this.newItem = newItem;
|
2006-06-01 03:50:34 +00:00
|
|
|
this.newCollection = newCollection;
|
2006-06-05 18:01:53 +00:00
|
|
|
this.onCollectionSelected = onCollectionSelected;
|
2006-05-30 22:06:33 +00:00
|
|
|
this.itemSelected = itemSelected;
|
2006-06-19 15:00:13 +00:00
|
|
|
this.deleteSelectedItem = deleteSelectedItem;
|
|
|
|
this.deleteSelectedCollection = deleteSelectedCollection;
|
2006-06-05 13:08:16 +00:00
|
|
|
this.renameSelectedCollection = renameSelectedCollection;
|
2006-05-30 22:06:33 +00:00
|
|
|
this.search = search;
|
2006-06-08 18:42:55 +00:00
|
|
|
this.getCollectionsView = getCollectionsView;
|
|
|
|
this.getItemsView = getItemsView;
|
2006-07-31 19:14:06 +00:00
|
|
|
this.selectItem = selectItem;
|
2006-07-24 22:12:25 +00:00
|
|
|
this.getSelectedCollection = getSelectedCollection;
|
2006-07-26 15:09:06 +00:00
|
|
|
this.getSelectedItems = getSelectedItems;
|
2006-06-19 15:00:13 +00:00
|
|
|
this.buildCollectionContextMenu = buildCollectionContextMenu;
|
|
|
|
this.buildItemContextMenu = buildItemContextMenu;
|
2006-08-02 16:08:19 +00:00
|
|
|
this.onDoubleClick = onDoubleClick;
|
2006-06-27 22:47:17 +00:00
|
|
|
this.openNoteWindow = openNoteWindow;
|
2006-07-26 14:30:38 +00:00
|
|
|
this.newNote = newNote;
|
2006-07-31 16:58:14 +00:00
|
|
|
this.addFileFromDialog = addFileFromDialog;
|
|
|
|
this.addFileFromPage = addFileFromPage;
|
2006-05-30 22:06:33 +00:00
|
|
|
|
2006-06-02 15:27:52 +00:00
|
|
|
/*
|
|
|
|
* Called when the window is open
|
|
|
|
*/
|
|
|
|
function onLoad()
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2006-07-19 16:14:27 +00:00
|
|
|
if(Scholar.Prefs.get("scholarPaneOnTop"))
|
2006-06-28 15:15:38 +00:00
|
|
|
{
|
2006-07-19 16:14:27 +00:00
|
|
|
var oldPane = document.getElementById('scholar-pane');
|
|
|
|
var oldSplitter = document.getElementById('scholar-splitter');
|
|
|
|
var appContent = document.getElementById('appcontent');
|
|
|
|
|
|
|
|
var newPane = document.createElement('hbox');
|
|
|
|
newPane.setAttribute('id','scholar-pane');
|
|
|
|
newPane.setAttribute('collapsed',true);
|
|
|
|
newPane.setAttribute('flex','1');
|
2006-07-27 18:08:09 +00:00
|
|
|
newPane.height = oldPane.height;
|
2006-07-19 16:14:27 +00:00
|
|
|
while(oldPane.hasChildNodes())
|
|
|
|
newPane.appendChild(oldPane.firstChild);
|
|
|
|
appContent.removeChild(oldPane);
|
|
|
|
appContent.insertBefore(newPane, document.getElementById('content'));
|
|
|
|
|
|
|
|
var newSplitter = document.createElement('splitter');
|
|
|
|
newSplitter.setAttribute('id','scholar-splitter');
|
|
|
|
newSplitter.setAttribute('collapsed',true);
|
|
|
|
newSplitter.setAttribute('resizebefore','closest');
|
|
|
|
newSplitter.setAttribute('resizeafter','closest');
|
|
|
|
appContent.removeChild(oldSplitter);
|
|
|
|
appContent.insertBefore(newSplitter, document.getElementById('content'));
|
2006-07-28 16:49:19 +00:00
|
|
|
|
|
|
|
document.getElementById('tb-fullscreen').setAttribute('scholartop','true');
|
2006-06-28 15:15:38 +00:00
|
|
|
}
|
|
|
|
|
2006-07-26 14:03:54 +00:00
|
|
|
//Initialize collections view
|
|
|
|
collectionsView = new Scholar.CollectionTreeView();
|
2006-07-28 13:28:50 +00:00
|
|
|
var collectionsTree = document.getElementById('collections-tree');
|
|
|
|
collectionsTree.view = collectionsView;
|
|
|
|
collectionsTree.controllers.appendController(new Scholar.CollectionTreeCommandController(collectionsTree));
|
|
|
|
|
|
|
|
var itemsTree = document.getElementById('items-tree');
|
|
|
|
itemsTree.controllers.appendController(new Scholar.ItemTreeCommandController(itemsTree));
|
2006-07-26 14:03:54 +00:00
|
|
|
|
2006-06-20 13:59:59 +00:00
|
|
|
//Create the add menu with each item type
|
|
|
|
var addMenu = document.getElementById('tb-add').firstChild;
|
|
|
|
var itemTypes = Scholar.ItemTypes.getTypes();
|
|
|
|
for(var i = 0; i<itemTypes.length; i++)
|
|
|
|
{
|
|
|
|
var menuitem = document.createElement("menuitem");
|
|
|
|
menuitem.setAttribute("label", Scholar.getString("itemTypes."+itemTypes[i]['name']));
|
|
|
|
menuitem.setAttribute("oncommand","ScholarPane.newItem("+itemTypes[i]['id']+")");
|
|
|
|
addMenu.appendChild(menuitem);
|
|
|
|
}
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
|
2006-06-02 15:27:52 +00:00
|
|
|
/*
|
|
|
|
* Called when the window closes
|
|
|
|
*/
|
|
|
|
function onUnload()
|
|
|
|
{
|
2006-06-05 18:01:53 +00:00
|
|
|
collectionsView.unregister();
|
2006-06-02 15:27:52 +00:00
|
|
|
if(itemsView)
|
|
|
|
itemsView.unregister();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hides/displays the Scholar interface
|
|
|
|
*/
|
|
|
|
function toggleDisplay()
|
2006-05-31 22:01:31 +00:00
|
|
|
{
|
2006-07-19 16:14:27 +00:00
|
|
|
var visible = document.getElementById('scholar-pane').getAttribute('collapsed') == 'true';
|
2006-05-31 22:01:31 +00:00
|
|
|
|
2006-07-19 16:14:27 +00:00
|
|
|
document.getElementById('scholar-pane').setAttribute('collapsed',!visible);
|
|
|
|
document.getElementById('scholar-splitter').setAttribute('collapsed',!visible);
|
2006-07-05 16:19:26 +00:00
|
|
|
|
|
|
|
if(!visible)
|
2006-07-28 16:49:19 +00:00
|
|
|
{
|
2006-07-05 16:19:26 +00:00
|
|
|
document.getElementById('content').setAttribute('collapsed', false);
|
2006-07-28 16:49:19 +00:00
|
|
|
document.getElementById('tb-fullscreen').setAttribute('fullscreenmode', false);
|
|
|
|
}
|
2006-07-05 16:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function fullScreen()
|
|
|
|
{
|
|
|
|
var visible = document.getElementById('content').getAttribute('collapsed') == 'true';
|
|
|
|
document.getElementById('content').setAttribute('collapsed', !visible);
|
2006-07-19 16:14:27 +00:00
|
|
|
document.getElementById('scholar-splitter').setAttribute('collapsed', !visible);
|
2006-07-28 16:49:19 +00:00
|
|
|
document.getElementById('tb-fullscreen').setAttribute('fullscreenmode', !visible);
|
2006-05-31 22:01:31 +00:00
|
|
|
}
|
2006-06-02 15:27:52 +00:00
|
|
|
|
|
|
|
/*
|
2006-06-17 00:57:50 +00:00
|
|
|
* Create a new item
|
2006-06-02 15:27:52 +00:00
|
|
|
*/
|
2006-05-30 22:06:33 +00:00
|
|
|
function newItem(typeID)
|
|
|
|
{
|
2006-06-19 15:00:13 +00:00
|
|
|
if(document.getElementById('tb-search').value != "")
|
|
|
|
{
|
|
|
|
document.getElementById('tb-search').value = "";
|
|
|
|
document.getElementById('tb-search').doCommand();
|
|
|
|
}
|
|
|
|
|
2006-06-17 00:57:50 +00:00
|
|
|
var item = new Scholar.Item(typeID);
|
|
|
|
item.save();
|
|
|
|
if(itemsView && itemsView._itemGroup.isCollection())
|
|
|
|
itemsView._itemGroup.ref.addItem(item.getID());
|
2006-06-19 15:00:13 +00:00
|
|
|
|
2006-06-25 04:57:52 +00:00
|
|
|
//set to Info tab
|
|
|
|
document.getElementById('scholar-view-item').selectedIndex = 0;
|
2006-08-04 14:23:44 +00:00
|
|
|
|
|
|
|
return item;
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
|
2006-06-01 03:50:34 +00:00
|
|
|
function newCollection()
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2006-06-05 17:47:36 +00:00
|
|
|
Scholar.Collections.add(Scholar.getString('pane.collections.untitled'));
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
|
2006-06-05 18:01:53 +00:00
|
|
|
function onCollectionSelected()
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2006-06-02 12:59:58 +00:00
|
|
|
if(itemsView)
|
|
|
|
itemsView.unregister();
|
2006-06-06 22:43:58 +00:00
|
|
|
|
|
|
|
document.getElementById('tb-search').value = "";
|
2006-06-21 22:23:42 +00:00
|
|
|
document.getElementById('scholar-search-options').hidden = true;
|
2006-07-24 22:12:25 +00:00
|
|
|
|
2006-06-05 18:01:53 +00:00
|
|
|
if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1)
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2006-06-05 18:01:53 +00:00
|
|
|
var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
|
2006-06-06 22:43:58 +00:00
|
|
|
collection.setSearch('');
|
2006-06-05 13:08:16 +00:00
|
|
|
|
|
|
|
itemsView = new Scholar.ItemTreeView(collection);
|
2006-05-30 22:06:33 +00:00
|
|
|
document.getElementById('items-tree').view = itemsView;
|
2006-06-20 17:08:30 +00:00
|
|
|
document.getElementById('tb-collection-rename').disabled = collection.isLibrary();
|
2006-06-13 20:45:30 +00:00
|
|
|
itemsView.selection.clearSelection();
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-01 18:50:16 +00:00
|
|
|
document.getElementById('items-tree').view = itemsView = null;
|
2006-06-20 17:08:30 +00:00
|
|
|
document.getElementById('tb-collection-rename').disabled = true;
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function itemSelected()
|
|
|
|
{
|
2006-06-02 15:27:52 +00:00
|
|
|
if(itemsView && itemsView.selection.count == 1 && itemsView.selection.currentIndex != -1)
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
|
|
|
var item = itemsView._getItemAtRow(itemsView.selection.currentIndex);
|
|
|
|
|
2006-06-27 20:37:02 +00:00
|
|
|
if(item.isNote())
|
|
|
|
{
|
2006-06-28 18:30:29 +00:00
|
|
|
var noteEditor = document.getElementById('scholar-note-editor');
|
|
|
|
noteEditor.item = null;
|
|
|
|
noteEditor.note = item.ref;
|
2006-08-02 16:08:19 +00:00
|
|
|
document.getElementById('scholar-view-note-button').setAttribute('noteID',item.ref.getID());
|
2006-07-31 19:14:06 +00:00
|
|
|
if(item.ref.getSource() != null)
|
2006-08-02 16:08:19 +00:00
|
|
|
document.getElementById('scholar-view-note-button').setAttribute('sourceID',item.ref.getSource());
|
2006-07-31 19:14:06 +00:00
|
|
|
else
|
2006-08-02 16:08:19 +00:00
|
|
|
document.getElementById('scholar-view-note-button').removeAttribute('sourceID');
|
2006-06-27 20:37:02 +00:00
|
|
|
document.getElementById('item-pane').selectedIndex = 2;
|
2006-07-27 18:08:09 +00:00
|
|
|
}
|
|
|
|
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;
|
2006-06-27 20:37:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-26 17:51:18 +00:00
|
|
|
ScholarItemPane.viewItem(item.ref);
|
2006-06-27 20:37:02 +00:00
|
|
|
document.getElementById('item-pane').selectedIndex = 1;
|
|
|
|
}
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-27 20:37:02 +00:00
|
|
|
document.getElementById('item-pane').selectedIndex = 0;
|
2006-06-20 13:59:59 +00:00
|
|
|
|
2006-06-27 20:37:02 +00:00
|
|
|
var label = document.getElementById('scholar-view-selected-label');
|
|
|
|
|
2006-06-20 13:59:59 +00:00
|
|
|
if(itemsView && itemsView.selection.count)
|
2006-06-21 23:22:37 +00:00
|
|
|
label.value = Scholar.getString('pane.item.selected.multiple').replace('%1', itemsView.selection.count);
|
2006-06-20 13:59:59 +00:00
|
|
|
else
|
2006-06-21 23:22:37 +00:00
|
|
|
label.value = Scholar.getString('pane.item.selected.zero');
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-06-19 15:00:13 +00:00
|
|
|
function deleteSelectedItem()
|
2006-05-30 22:06:33 +00:00
|
|
|
{
|
2006-07-31 19:14:06 +00:00
|
|
|
if(itemsView && itemsView.selection.count > 0)
|
|
|
|
{
|
|
|
|
var eraseChildren = {};
|
|
|
|
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPromptService);
|
|
|
|
|
2006-08-02 17:57:16 +00:00
|
|
|
if(promptService.confirmCheck(window, Scholar.getString('pane.items.delete.title'), Scholar.getString('pane.items.delete'), Scholar.getString('pane.items.delete.attached'), eraseChildren))
|
2006-07-31 19:14:06 +00:00
|
|
|
itemsView.deleteSelection(eraseChildren.value);
|
|
|
|
}
|
2006-05-30 22:06:33 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 15:00:13 +00:00
|
|
|
function deleteSelectedCollection()
|
2006-06-02 14:11:23 +00:00
|
|
|
{
|
2006-06-05 18:01:53 +00:00
|
|
|
if(collectionsView.selection.count > 0 && confirm(Scholar.getString('pane.collections.delete')))
|
|
|
|
collectionsView.deleteSelection();
|
2006-06-02 14:11:23 +00:00
|
|
|
}
|
|
|
|
|
2006-06-05 13:08:16 +00:00
|
|
|
function renameSelectedCollection()
|
|
|
|
{
|
2006-06-05 18:01:53 +00:00
|
|
|
if(collectionsView.selection.count > 0)
|
2006-06-05 13:08:16 +00:00
|
|
|
{
|
2006-07-24 22:12:25 +00:00
|
|
|
var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
|
2006-06-05 13:08:16 +00:00
|
|
|
|
2006-06-05 17:47:36 +00:00
|
|
|
var newName = prompt(Scholar.getString('pane.collections.rename'),collection.getName());
|
2006-06-05 13:08:16 +00:00
|
|
|
if(newName)
|
|
|
|
collection.ref.rename(newName);
|
|
|
|
}
|
|
|
|
}
|
2006-06-06 19:53:27 +00:00
|
|
|
|
2006-05-30 22:06:33 +00:00
|
|
|
function search()
|
|
|
|
{
|
2006-06-01 16:40:43 +00:00
|
|
|
if(itemsView)
|
2006-06-21 22:23:42 +00:00
|
|
|
{
|
|
|
|
searchVal = document.getElementById('tb-search').value;
|
|
|
|
itemsView.searchText(searchVal);
|
|
|
|
|
|
|
|
//do something about granularity
|
|
|
|
//document.getElementById('scholar-search-options').getElementsByAttribute('checked','true')[0].label
|
|
|
|
|
|
|
|
document.getElementById('scholar-search-options').hidden = searchVal == "";
|
2006-08-01 18:01:48 +00:00
|
|
|
document.getElementById('tb-search-cancel').hidden = searchVal == "";
|
2006-06-21 22:23:42 +00:00
|
|
|
}
|
|
|
|
|
2006-06-01 16:40:43 +00:00
|
|
|
}
|
2006-06-08 18:42:55 +00:00
|
|
|
|
|
|
|
function getCollectionsView()
|
|
|
|
{
|
|
|
|
return collectionsView;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getItemsView()
|
|
|
|
{
|
|
|
|
return itemsView;
|
2006-06-02 12:59:58 +00:00
|
|
|
}
|
2006-06-19 15:00:13 +00:00
|
|
|
|
2006-07-31 19:14:06 +00:00
|
|
|
function selectItem(id)
|
|
|
|
{
|
|
|
|
if(itemsView)
|
|
|
|
{
|
|
|
|
if(!itemsView._itemGroup.isLibrary())
|
|
|
|
{
|
|
|
|
//select the Library if the item is not in the current collection
|
|
|
|
|
|
|
|
var item = Scholar.Items.get(id);
|
|
|
|
var collectionID = itemsView._itemGroup.ref.getID();
|
|
|
|
if(!item.isRegularItem())
|
|
|
|
{
|
|
|
|
if(!Scholar.Items.get(item.getSource()).inCollection(collectionID))
|
|
|
|
collectionsView.selection.select(0);
|
|
|
|
}
|
|
|
|
else if(!item.inCollection(collectionID))
|
|
|
|
collectionsView.selection.select(0);
|
|
|
|
}
|
|
|
|
itemsView.selectItem(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-24 22:12:25 +00:00
|
|
|
function getSelectedCollection()
|
|
|
|
{
|
|
|
|
if(collectionsView.selection.count > 0 && collectionsView.selection.currentIndex != -1)
|
|
|
|
{
|
|
|
|
collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
|
|
|
|
if(collection && collection.isCollection())
|
|
|
|
return collection.ref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-26 15:09:06 +00:00
|
|
|
function getSelectedItems()
|
2006-07-24 22:12:25 +00:00
|
|
|
{
|
2006-07-26 15:09:06 +00:00
|
|
|
if(itemsView)
|
2006-07-24 22:12:25 +00:00
|
|
|
{
|
2006-07-26 15:09:06 +00:00
|
|
|
var items = new Array();
|
|
|
|
var start = new Object();
|
|
|
|
var end = new Object();
|
|
|
|
for (var i=0, len=itemsView.selection.getRangeCount(); i<len; i++)
|
|
|
|
{
|
|
|
|
itemsView.selection.getRangeAt(i,start,end);
|
|
|
|
for (var j=start.value; j<=end.value; j++)
|
|
|
|
items.push(itemsView._getItemAtRow(j).ref);
|
|
|
|
}
|
2006-07-24 22:12:25 +00:00
|
|
|
}
|
2006-07-26 15:09:06 +00:00
|
|
|
return items;
|
2006-07-24 22:12:25 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 15:00:13 +00:00
|
|
|
function buildCollectionContextMenu()
|
|
|
|
{
|
|
|
|
var menu = document.getElementById('scholar-collectionmenu');
|
|
|
|
|
|
|
|
if(collectionsView.selection.count == 1 && !collectionsView._getItemAtRow(collectionsView.selection.currentIndex).isLibrary())
|
|
|
|
{
|
|
|
|
menu.childNodes[2].removeAttribute('disabled');
|
|
|
|
menu.childNodes[3].removeAttribute('disabled');
|
2006-07-26 15:28:31 +00:00
|
|
|
menu.childNodes[5].removeAttribute('disabled');
|
|
|
|
menu.childNodes[6].removeAttribute('disabled');
|
2006-06-19 15:00:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menu.childNodes[2].setAttribute('disabled', true);
|
|
|
|
menu.childNodes[3].setAttribute('disabled', true);
|
2006-07-26 15:28:31 +00:00
|
|
|
menu.childNodes[5].setAttribute('disabled', true);
|
|
|
|
menu.childNodes[6].setAttribute('disabled', true);
|
2006-06-19 15:00:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function buildItemContextMenu()
|
|
|
|
{
|
|
|
|
var menu = document.getElementById('scholar-itemmenu');
|
|
|
|
|
|
|
|
if(itemsView && itemsView.selection.count > 0)
|
2006-07-26 15:28:31 +00:00
|
|
|
{
|
2006-06-19 15:00:13 +00:00
|
|
|
menu.childNodes[2].removeAttribute('disabled');
|
2006-07-26 15:28:31 +00:00
|
|
|
menu.childNodes[4].removeAttribute('disabled');
|
|
|
|
menu.childNodes[5].removeAttribute('disabled');
|
|
|
|
}
|
2006-06-19 15:00:13 +00:00
|
|
|
else
|
2006-07-26 15:28:31 +00:00
|
|
|
{
|
2006-06-19 15:00:13 +00:00
|
|
|
menu.childNodes[2].setAttribute('disabled', true);
|
2006-07-26 15:28:31 +00:00
|
|
|
menu.childNodes[4].setAttribute('disabled', true);
|
|
|
|
menu.childNodes[5].setAttribute('disabled', true);
|
|
|
|
}
|
2006-06-19 15:00:13 +00:00
|
|
|
|
|
|
|
if(itemsView && itemsView.selection.count > 1)
|
2006-07-26 15:28:31 +00:00
|
|
|
{
|
2006-06-21 23:22:37 +00:00
|
|
|
menu.childNodes[2].setAttribute('label', Scholar.getString('pane.items.menu.remove.multiple'));
|
2006-07-26 15:28:31 +00:00
|
|
|
menu.childNodes[4].setAttribute('label', Scholar.getString('pane.items.menu.export.multiple'));
|
|
|
|
menu.childNodes[5].setAttribute('label', Scholar.getString('pane.items.menu.createBib.multiple'));
|
|
|
|
}
|
2006-06-19 15:00:13 +00:00
|
|
|
else
|
2006-07-26 15:28:31 +00:00
|
|
|
{
|
|
|
|
menu.childNodes[2].setAttribute('label', Scholar.getString('pane.items.menu.remove'));
|
|
|
|
menu.childNodes[4].setAttribute('label', Scholar.getString('pane.items.menu.export'));
|
|
|
|
menu.childNodes[5].setAttribute('label', Scholar.getString('pane.items.menu.createBib'));
|
|
|
|
}
|
2006-06-19 15:00:13 +00:00
|
|
|
}
|
2006-06-27 22:47:17 +00:00
|
|
|
|
2006-08-02 16:08:19 +00:00
|
|
|
// Adapted from: http://www.xulplanet.com/references/elemref/ref_tree.html#cmnote-9
|
|
|
|
function onDoubleClick(event, tree)
|
|
|
|
{
|
|
|
|
if (event && tree && (event.type == "click" || event.type == "dblclick"))
|
|
|
|
{
|
|
|
|
var row = {}, col = {}, obj = {};
|
|
|
|
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj);
|
|
|
|
if (obj.value && itemsView && itemsView.selection.currentIndex > -1)
|
|
|
|
{
|
|
|
|
var item = getSelectedItems()[0];
|
|
|
|
if(item && item.isNote())
|
|
|
|
{
|
|
|
|
document.getElementById('scholar-view-note-button').doCommand();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-26 14:30:38 +00:00
|
|
|
function newNote()
|
2006-06-27 22:47:17 +00:00
|
|
|
{
|
2006-07-26 14:30:38 +00:00
|
|
|
var c = getSelectedCollection();
|
|
|
|
if(c)
|
|
|
|
openNoteWindow(null, c.getID());
|
|
|
|
else
|
|
|
|
openNoteWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
function openNoteWindow(id, parent)
|
|
|
|
{
|
|
|
|
window.open('chrome://scholar/content/note.xul?v=1'+(id ? '&id='+id : '')+(parent ? '&coll='+parent : ''),'','chrome,resizable,centerscreen');
|
2006-06-27 22:47:17 +00:00
|
|
|
}
|
2006-07-31 16:58:14 +00:00
|
|
|
|
|
|
|
function addFileFromDialog(link, id)
|
|
|
|
{
|
|
|
|
var nsIFilePicker = Components.interfaces.nsIFilePicker;
|
|
|
|
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
|
|
|
.createInstance(nsIFilePicker);
|
2006-08-02 17:57:16 +00:00
|
|
|
fp.init(window, Scholar.getString('pane.item.files.select'), nsIFilePicker.modeOpen);
|
2006-07-31 16:58:14 +00:00
|
|
|
|
|
|
|
if(fp.show() == nsIFilePicker.returnOK)
|
|
|
|
{
|
2006-07-31 19:14:06 +00:00
|
|
|
var fileID;
|
2006-07-31 16:58:14 +00:00
|
|
|
if(link)
|
2006-07-31 19:14:06 +00:00
|
|
|
fileID = Scholar.Files.linkFromFile(fp.file, id);
|
2006-07-31 16:58:14 +00:00
|
|
|
else
|
2006-07-31 19:14:06 +00:00
|
|
|
fileID = Scholar.Files.importFromFile(fp.file, id);
|
|
|
|
|
|
|
|
if(fileID && !id)
|
|
|
|
{
|
|
|
|
var c = getSelectedCollection();
|
|
|
|
if(c)
|
|
|
|
c.addItem(fileID);
|
|
|
|
}
|
2006-07-31 16:58:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function addFileFromPage(link, id)
|
|
|
|
{
|
2006-08-04 14:23:44 +00:00
|
|
|
var item;
|
|
|
|
if(id == null)
|
|
|
|
{
|
|
|
|
item = newItem(Scholar.ItemTypes.getID('website'));
|
|
|
|
if(item)
|
|
|
|
id = item.getID();
|
|
|
|
}
|
|
|
|
|
2006-07-31 19:14:06 +00:00
|
|
|
var fileID;
|
2006-07-31 16:58:14 +00:00
|
|
|
if(link)
|
2006-07-31 19:14:06 +00:00
|
|
|
fileID = Scholar.Files.linkFromDocument(window.content.document, id);
|
2006-07-31 16:58:14 +00:00
|
|
|
else
|
2006-07-31 19:14:06 +00:00
|
|
|
fileID = Scholar.Files.importFromDocument(window.content.document, id);
|
|
|
|
|
2006-08-04 14:23:44 +00:00
|
|
|
if(fileID)
|
2006-07-31 19:14:06 +00:00
|
|
|
{
|
2006-08-04 14:23:44 +00:00
|
|
|
var file = Scholar.Items.get(fileID);
|
|
|
|
if(!item)
|
|
|
|
item = Scholar.Items.get(id);
|
|
|
|
|
|
|
|
if(file && item)
|
|
|
|
{
|
|
|
|
item.setField('title',file.getField('title'));
|
|
|
|
item.save();
|
|
|
|
}
|
2006-07-31 19:14:06 +00:00
|
|
|
}
|
2006-07-31 16:58:14 +00:00
|
|
|
}
|
2006-06-02 12:59:58 +00:00
|
|
|
}
|
|
|
|
|
2006-06-02 15:27:52 +00:00
|
|
|
window.addEventListener("load", function(e) { ScholarPane.onLoad(e); }, false);
|
|
|
|
window.addEventListener("unload", function(e) { ScholarPane.onUnload(e); }, false);
|