Removed organizeWindow.xul/js (All this functionality is in overlay)

Removed view.xul/js/css (see above)
Enabled deletion (exception when deleting from library)
This commit is contained in:
David Norton 2006-06-01 16:40:43 +00:00
parent b9a5c7dc38
commit c1241b608a
11 changed files with 106 additions and 412 deletions

View file

@ -100,8 +100,11 @@ Scholar.ItemTreeView.prototype.deleteSelection = function()
this._treebox.beginUpdateBatch();
for (var i=0; i<rows.length; i++)
{
//erase item/folder from DB
this._getItemAtRow(rows[i]-i).erase();
if(this._itemGroup.isLibrary()) //erase item from DB
this._getItemAtRow(rows[i]-i).erase();
else if(this._itemGroup.isCollection())
this._itemGroup.ref.removeItem(this._getItemAtRow(rows[i]-i).getID());
//remove row from tree:
this._hideItem(rows[i]-i);
@ -112,6 +115,12 @@ Scholar.ItemTreeView.prototype.deleteSelection = function()
this._refreshHashMap();
}
Scholar.ItemTreeView.prototype.searchText = function(search)
{
//does nothing, right now.
// this._refreshHashMap();
}
Scholar.ItemTreeView.prototype._refreshHashMap = function()
{
// Create hash map of folder and object ids to row indexes

View file

@ -15,7 +15,7 @@ MetadataPane = new function()
function init()
{
_metadataPane = document.getElementById('metadata-pane');
_metadataPane = document.getElementById('scholar-metadata');
_dynamicFields = document.getElementById('editpane-dynamic-fields');
_dynamicCreators = document.getElementById('editpane-dynamic-creators');
_editButton = document.getElementById('metadata-pane-edit-button');
@ -194,4 +194,4 @@ MetadataPane = new function()
}
}
document.addEventListener("load", function(e) { MetadataPane.init(e); }, false);
addEventListener("load", function(e) { MetadataPane.init(e); }, false);

View file

@ -5,7 +5,7 @@
<script src="metadataPane.js"/>
<vbox id="metadata">
<vbox id="scholar-metadata">
<grid>
<columns>
<column/>

View file

@ -1,108 +0,0 @@
var foldersView;
var itemsView;
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
function init()
{
foldersView = new Scholar.TreeView(0); //pass params here?
document.getElementById('folders-tree').view = foldersView;
itemsView = new Scholar.ItemTreeView(0);
document.getElementById('items-tree').view = itemsView;
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","newItem("+itemTypes[i]['id']+")");
addMenu.appendChild(menuitem);
}
}
function newItem(typeID)
{
alert("new item of type: "+typeID);
}
function newFolder()
{
alert("new folder");
}
function folderSelected()
{
if(foldersView.selection.count == 1 && foldersView.selection.currentIndex != -1)
{
itemsView = new Scholar.ItemTreeView(foldersView._getItemAtRow(foldersView.selection.currentIndex).getID());
document.getElementById('items-tree').view = itemsView;
}
else if(foldersView.selection.count == 0)
{
itemsView = new Scholar.ItemTreeView(0);
document.getElementById('items-tree').view = itemsView;
}
else
{
document.getElementById('items-tree').view = null;
}
}
function itemSelected()
{
var tabs = document.getElementById('item-tabs');
var editButton = document.getElementById('metadata-pane-edit-button');
if(editButton.checked)
{
var flags=promptService.BUTTON_TITLE_SAVE * promptService.BUTTON_POS_0 +
promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1 +
promptService.BUTTON_TITLE_DONT_SAVE * promptService.BUTTON_POS_2;
var response = promptService.confirmEx(window,"",
"Do you want to save the changes?", // to '"+_itemBeingEdited.getField("title")+"'
flags, null, null, null, null, {});
if(response == 1)
return;
else if(response == 0)
MetadataPane.toggleEdit();
else
editButton.checked = false;
}
if(itemsView && itemsView.selection.count == 1)
{
var item = itemsView._getItemAtRow(itemsView.selection.currentIndex);
tabs.hidden=false;
if(tabs.firstChild.selectedIndex == 0)
{
document.getElementById('view-pane').setAttribute('src','http://www.google.com/search?q='+encodeURIComponent('"'+item.getField("title")+'"')+'&btnI');
}
else if(tabs.firstChild.selectedIndex == 1)
{
MetadataPane.viewItem(item);
}
else
{
//do notes
}
}
else
{
tabs.hidden=true;
}
}
function deleteSelection()
{
if(itemsView && itemsView.selection.count > 0 && confirm("Are you sure you want to delete the selected items?"))
itemsView.deleteSelection();
}
function search()
{
//TO DO: reload items tree with a search instead of a root folder
alert(document.getElementById('tb-search').value);
}

View file

@ -1,179 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
<?xul-overlay href="chrome://browser/content/baseMenuOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<window
id="scholar-window"
title="Scholar"
orient="vertical"
width="1000" height="700" screenX="20" screenY="20"
persist="width height screenX screenY sizemode"
windowtype="scholar:window"
onload="init();"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<?xul-overlay href="metadataPane.xul"?>
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>
<script type="application/x-javascript" src="chrome://browser/content/utilityOverlay.js"/>
<!-- Include the global XPCOM object -->
<script src="include.js"/>
<script src="organizeWindow.js"/>
<script src="itemTreeView.js"/>
<script src="folderTreeView.js"/>
<commandset id="baseMenuCommandSet" />
<keyset id="baseMenuKeyset" />
<keyset id="editMenuKeys"/>
<command id="cmd_close" oncommand="closeWindow(true);"/>
<command id="cmd_delete" oncommand="deleteSelection()"/>
<command id="cmd_scholar_newItem" oncommand="newItem(1);"/>
<command id="cmd_scholar_newFolder" oncommand="newFolder();"/>
<command id="cmd_scholar_search" oncommand="search();"/>
<keyset>
<key id="delete-cmd" keycode="VK_DELETE" command="cmd_delete"/>
<key id="backspace-cmd" keycode="VK_BACK" command="cmd_delete"/>
<key id="key_close" key="&closeCmd.commandkey;" modifiers="accel" command="cmd_close"/>
</keyset>
<toolbox>
<menubar id="main-menubar">
<menu label="&fileMenu.label;" accesskey="&fileMenu.accesskey;">
<menupopup>
<menuitem label="&menuitem.newItem.label;"
accesskey="&menuitem.newItem.accesskey;"
command="cmd_scholar_newItem"/>
<menuitem label="&menuitem.newFolder.label;"
accesskey="&menuitem.newFolder.accesskey;"
command="cmd_scholar_newFolder"/>
<menuseparator/>
<menuitem label="Import..." disabled="true"/>
<menuitem label="Export..." disabled="true"/>
<menuseparator/>
<menuitem label="&closeCmd.label;" command="cmd_close"
key="key_close" accesskey="&closeCmd.accesskey;"/>
</menupopup>
</menu>
<menu id="menu_edit">
<menupopup>
<menuitem id="menu_undo"/>
<menuitem id="menu_redo"/>
<menuseparator/>
<menuitem id="menu_cut"/>
<menuitem id="menu_copy"/>
<menuitem id="menu_paste"/>
<menuitem id="menu_delete" command="cmd_delete"/>
<menuseparator/>
<menuitem id="menu_selectAll"/>
</menupopup>
</menu>
#ifdef XP_MACOSX
<menu id="windowMenu"/>
<menupopup id="menu_ToolsPopup"/>
#endif
<menu id="helpMenu"/>
</menubar>
<toolbar>
<toolbarbutton label="&menuitem.newFolder.label;" command="cmd_scholar_newFolder"/>
<toolbarbutton id="tb-add" label="&menuitem.newItem.label;" type="menu">
<menupopup>
</menupopup>
</toolbarbutton>
<spacer flex="1"/>
<label value="Search:" control="tb-search"/>
<textbox id="tb-search" type="timed" timeout="500" width="150" command="cmd_scholar_search"/>
</toolbar>
</toolbox>
<hbox flex="1">
<vbox id="folders-pane" flex="1">
<tree id="folders-tree"
treeviewtype="folders" style="-moz-user-focus: ignore;" hidecolumnpicker="true"
onselect="folderSelected();"
persist="width" flex="1">
<treecols>
<treecol
id="name_column"
label="&folders.name_column;"
flex="1"
primary="true"/>
</treecols>
<treechildren/>
</tree>
</vbox>
<splitter collapse="before" resizebefore="closest" resizeafter="closest" persist="state">
<grippy/>
</splitter>
<vbox flex="4" persist="width">
<tree
id="items-tree"
enableColumnDrag="true"
onselect="itemSelected();"
persist="height" flex="1">
<treecols>
<treecol
id="title"
label="&items.title_column;"
flex="4" persist="width ordinal hidden"/>
<splitter class="tree-splitter"/>
<treecol
id="firstCreator"
label="&items.creator_column;"
flex="1" persist="width ordinal hidden"/>
<splitter class="tree-splitter"/>
<treecol
id="source"
label="&items.source_column;"
flex="1" persist="width ordinal hidden"/>
<splitter class="tree-splitter"/>
<treecol
id="rights" hidden="true"
label="&items.rights_column;"
flex="1" persist="width ordinal hidden"/>
<splitter class="tree-splitter"/>
<treecol
id="dateAdded" hidden="true"
label="&items.dateAdded_column;"
flex="1" persist="width ordinal hidden"/>
<splitter class="tree-splitter"/>
<treecol
id="dateModified" hidden="true"
label="&items.dateModified_column;"
flex="1" persist="width ordinal hidden"/>
</treecols>
<treechildren/>
</tree>
<splitter collapse="after" resizebefore="closest" resizeafter="closest" persist="state">
<grippy/>
</splitter>
<tabbox id="item-tabs" flex="3" persist="height" hidden="true">
<tabs onselect="itemSelected();">
<tab label="Item"/>
<tab label="Metadata"/>
<tab label="Notes"/>
</tabs>
<tabpanels flex="1">
<iframe id="view-pane" src="" type="content" flex="1"/>
<vbox id="metadata-pane"/>
<tabpanel/>
</tabpanels>
</tabbox>
</vbox>
</hbox>
<statusbar id="statusbar">
<statuspanel id="statusbar-text" flex="1"/>
</statusbar>
</window>

View file

@ -13,6 +13,7 @@ var ScholarPane = new function()
this.itemSelected = itemSelected;
this.deleteSelection = deleteSelection;
this.search = search;
this.toggleView = toggleView;
function init()
{
@ -29,6 +30,8 @@ var ScholarPane = new function()
menuitem.setAttribute("oncommand","ScholarPane.newItem("+itemTypes[i]['id']+")");
addMenu.appendChild(menuitem);
}
// Drag.init(document.getElementById('scholar-floater-handle'),document.getElementById('scholar-floater'), 0, 400, 0, 500, true, true);
}
function toggleScholar()
@ -75,10 +78,17 @@ var ScholarPane = new function()
{
var item = itemsView._getItemAtRow(itemsView.selection.currentIndex);
document.getElementById('content').loadURI('chrome://scholar/content/view.xul?id='+encodeURIComponent(item.getID()));
MetadataPane.viewItem(item);
var url = item.getField('source');
if(!validURL(url))
url = 'http://www.google.com/search?q='+encodeURIComponent('"'+item.getField("title")+'"'); //+'&btnI'
document.getElementById('content').loadURI(url);
document.getElementById('scholar-floater').hidden=false;
}
else
{
document.getElementById('scholar-floater').hidden=true;
}
@ -92,8 +102,25 @@ var ScholarPane = new function()
function search()
{
//TO DO: reload items tree with a search instead of a root folder
alert(document.getElementById('tb-search').value);
if(itemsView)
itemsView.searchText(document.getElementById('tb-search').value);
}
function toggleView(id)
{
var button = document.getElementById('tb-'+id);
var elem = document.getElementById('scholar-'+id);
button.checked = !button.checked;
elem.hidden = !elem.hidden;
}
//Thanks: http://www.bigbold.com/snippets/posts/show/452
//TODO: move this out of overlay.js, into Scholar.js?
function validURL(s)
{
var regexp = /(http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
return regexp.test(s);
}
}

View file

@ -1,10 +1,10 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/overlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<overlay id="scholar"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<?xul-overlay href="metadataPane.xul" ?>
<!-- Include the global XPCOM object -->
<script src="include.js"/>
@ -19,6 +19,19 @@
<command id="cmd_scholar_search" oncommand="ScholarPane.search();"/>
</commandset>
<window id="main-window">
<vbox id="scholar-floater" hidden="true">
<toolbar id="scholar-floater-handle">
<label value="Scholar Quick Info"/>
<spacer flex="1"/>
</toolbar>
<vbox id="scholar-metadata"/>
<vbox id="scholar-notes">
<textbox value="Notes.... lorem ispum delorum..." multiline="true" flex="1"/>
</vbox>
</vbox>
</window>
<vbox id="appcontent">
<vbox id="scholar-pane" position="1" persist="height collapsed">
<hbox flex="1">
@ -37,7 +50,7 @@
<splitter id="scholar-tree-splitter" resizebefore="closest" resizeafter="closest"/>
<tree
id="items-tree"
enableColumnDrag="true"
enableColumnDrag="true" onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteSelection(); return false; }"
onselect="ScholarPane.itemSelected();"
persist="width" flex="5">
<treecols>
@ -82,6 +95,10 @@
</menupopup>
</toolbarbutton>
<spacer flex="1"/>
<!-- <toolbarbutton class="scholar-toggler" id="tb-view" label="View" checked="true" oncommand="ScholarPane.toggleView('view')"/> -->
<toolbarbutton class="scholar-toggler" id="tb-metadata" label="Metadata" checked="true" oncommand="ScholarPane.toggleView('metadata')"/>
<toolbarbutton class="scholar-toggler" id="tb-notes" label="Notes" checked="true" oncommand="ScholarPane.toggleView('notes')"/>
<spacer flex="1"/>
<label value="Search:" control="tb-search"/>
<textbox id="tb-search" type="timed" timeout="500" command="cmd_scholar_search"/>
<toolbarbutton class="tabs-closebutton" oncommand="ScholarPane.toggleScholar()"/>

View file

@ -1,48 +0,0 @@
var thisItem;
function init()
{
if(thisItem)
return;
var id = getArgument("id");
if(id)
{
thisItem = Scholar.Items.get(id);
document.getElementById('view').setAttribute('src','http://www.google.com/search?q='+encodeURIComponent('"'+thisItem.getField("title")+'"')+'&btnI');
MetadataPane.viewItem(thisItem);
}
else
{
thisItem = new Scholar.Item(getArgument('new'));
MetadataPane.viewItem(thisItem);
MetadataPane.toggleEdit();
}
}
function toggle(id)
{
var button = document.getElementById('tb-'+id);
var elem = document.getElementById(id);
button.checked = !button.checked;
elem.hidden = !elem.hidden;
}
//thanks to: http://evolt.org/node/14435
function getArgument (name)
{
var arguments = document.location.search.slice(1).split('&');
var r = '';
for (var i = 0; i < arguments.length; i++)
{
if (arguments[i].slice(0,arguments[i].indexOf('=')) == name)
{
r = arguments[i].slice(arguments[i].indexOf('=')+1);
return (r.length > 0 ? unescape(r).split(',') : '');
}
}
return '';
}
addEventListener("load", function(e) { init(e); }, false);

View file

@ -1,26 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://scholar/skin/scholar.css" type="text/css"?>
<?xml-stylesheet href="chrome://scholar/skin/view.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/browser.css" type="text/css"?>
<page
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="view.js"/>
<script src="include.js"/>
<?xul-overlay href="metadataPane.xul" ?>
<stack flex="1">
<browser id="view" flex="1"/>
<vbox align="end">
<vbox id="metadata" class="floater"/>
<vbox id="notes" class="floater">
<textbox value="Notes.... lorem ispum delorum..." multiline="true" flex="1"/>
</vbox>
</vbox>
</stack>
<toolbar id="view-toolbar">
<toolbarbutton class="toggler" id="tb-view" label="View" checked="true" oncommand="toggle('view')"/>
<toolbarbutton class="toggler" id="tb-metadata" label="Metadata" checked="true" oncommand="toggle('metadata')"/>
<toolbarbutton class="toggler" id="tb-notes" label="Notes" checked="true" oncommand="toggle('notes')"/>
</toolbar>
</page>

View file

@ -33,6 +33,11 @@ tree #items-tree
}
#scholar-toolbar .toggler
{
margin: 4px;
}
#tb-search
{
width: 150px;
@ -45,4 +50,42 @@ tree #items-tree
min-height: 4px;
max-height: 4px;
background: #f5f5f5 !important;
}
#scholar-floater
{
position: fixed;
bottom: 0px;
right: 0px;
margin-bottom: 30px;
margin-right: 30px;
border: 1px solid #a5a5a5;
padding: 5px;
background: #f5f5f5;
font-size: 12px;
width: 400px;
max-width: 400px;
}
#scholar-floater vbox, #scholar-floater toolbar
{
width: 400px;
max-width: 400px;
margin-top: 5px;
padding: none;
}
#scholar-metadata
{
}
#scholar-metadata toolbar
{
border-bottom: none;
}
#scholar-notes
{
height: 100px;
}

View file

@ -1,41 +0,0 @@
#view-toolbar
{
background: #f5f5f5;
}
#view-toolbar .toggler
{
margin: 4px;
}
#subs
{
width: 400px;
}
.floater
{
position: relative;
margin-top: 10px;
margin-right: 30px;
padding: 5px;
font-size: 12px;
background: #f5f5f5;
width: 400px;
}
#metadata
{
}
#notes
{
height: 100px;
}
#metadata toolbar
{
border-bottom: none;
}