Fixes #120, Scholar preference for Above Content breaks display.

Changes the edit pane to look a lot better (uses groupbox).
Individual tabs don't load their content unless selected.
This commit is contained in:
David Norton 2006-07-26 14:03:54 +00:00
parent 16a995df86
commit a08bbe5347
7 changed files with 138 additions and 100 deletions

View file

@ -195,10 +195,10 @@
<xul:label id="seeAlsoLabel" class="clicky" crop="end" onclick="this.parentNode.parentNode.seeAlsoClick();"/> <xul:label id="seeAlsoLabel" class="clicky" crop="end" onclick="this.parentNode.parentNode.seeAlsoClick();"/>
<xul:label id="tagsLabel" class="clicky" crop="end" onclick="this.parentNode.parentNode.tagsClick();"/> <xul:label id="tagsLabel" class="clicky" crop="end" onclick="this.parentNode.parentNode.tagsClick();"/>
<xul:popupset> <xul:popupset>
<xul:popup id="seeAlsoPopup" width="300" onpopupshowing="this.firstChild.reload();" onpopuphiding="this.parentNode.parentNode.parentNode.updateSeeAlsoSummary();"> <xul:popup id="seeAlsoPopup" width="300" onpopupshowing="this.firstChild.reload();">
<xul:seealsobox id="seeAlso" flex="1"/> <xul:seealsobox id="seeAlso" flex="1"/>
</xul:popup> </xul:popup>
<xul:popup id="tagsPopup" width="300" onpopupshowing="this.firstChild.reload();" onpopuphiding="this.parentNode.parentNode.parentNode.updateTagsSummary();"> <xul:popup id="tagsPopup" width="300" onpopupshowing="this.firstChild.reload();">
<xul:tagsbox id="tags" flex="1"/> <xul:tagsbox id="tags" flex="1"/>
</xul:popup> </xul:popup>
</xul:popupset> </xul:popupset>
@ -212,6 +212,7 @@
<setter> <setter>
<![CDATA[ <![CDATA[
this.itemRef = val; this.itemRef = val;
this.reload();
]]> ]]>
</setter> </setter>
</property> </property>
@ -291,7 +292,6 @@
if(t && this.item) if(t && this.item)
{ {
this.item.addTag(t); this.item.addTag(t);
this.parentNode.parentNode.parentNode.parentNode.updateTagsSummary();
} }
]]> ]]>
</body> </body>
@ -360,6 +360,7 @@
<setter> <setter>
<![CDATA[ <![CDATA[
this.itemRef = val; this.itemRef = val;
this.reload();
]]> ]]>
</setter> </setter>
</property> </property>
@ -443,7 +444,6 @@
{ {
this.item.addSeeAlso(io.dataOut[i]); this.item.addSeeAlso(io.dataOut[i]);
} }
this.parentNode.parentNode.parentNode.parentNode.updateSeeAlsoSummary();
} }
]]> ]]>
</body> </body>

View file

@ -9,10 +9,13 @@ ScholarItemPane = new function()
var _creatorCount; var _creatorCount;
var _loaded;
var _itemBeingEdited; var _itemBeingEdited;
this.onLoad = onLoad; this.onLoad = onLoad;
this.viewItem = viewItem; this.viewItem = viewItem;
this.loadPane = loadPane;
this.changeTypeTo = changeTypeTo; this.changeTypeTo = changeTypeTo;
this.addCreatorRow = addCreatorRow; this.addCreatorRow = addCreatorRow;
this.removeCreator = removeCreator; this.removeCreator = removeCreator;
@ -25,12 +28,14 @@ ScholarItemPane = new function()
function onLoad() function onLoad()
{ {
_tabs = document.getElementById('scholar-view-tabs');
_dynamicFields = document.getElementById('editpane-dynamic-fields'); _dynamicFields = document.getElementById('editpane-dynamic-fields');
_itemTypeMenu = document.getElementById('editpane-type-menu'); _itemTypeMenu = document.getElementById('editpane-type-menu');
_creatorTypeMenu = document.getElementById('creatorTypeMenu'); _creatorTypeMenu = document.getElementById('creatorTypeMenu');
_notesList = document.getElementById('editpane-dynamic-notes'); _notesList = document.getElementById('editpane-dynamic-notes');
_notesLabel = document.getElementById('editpane-notes-label'); _notesLabel = document.getElementById('editpane-notes-label');
_linksBox = document.getElementById('editpane-links'); _tagsBox = document.getElementById('editpane-tags');
_relatedBox = document.getElementById('editpane-related');
var creatorTypes = Scholar.CreatorTypes.getTypes(); var creatorTypes = Scholar.CreatorTypes.getTypes();
for(var i = 0; i < creatorTypes.length; i++) for(var i = 0; i < creatorTypes.length; i++)
@ -58,91 +63,118 @@ ScholarItemPane = new function()
{ {
_itemBeingEdited = thisItem; _itemBeingEdited = thisItem;
reloadFields(); _loaded = new Array(5);
loadPane(_tabs.selectedIndex);
} }
function reloadFields() function loadPane(index)
{ {
while(_dynamicFields.hasChildNodes()) if(_loaded[index])
_dynamicFields.removeChild(_dynamicFields.firstChild); return;
_loaded[index] = true;
for(var i = 0, len = _itemTypeMenu.firstChild.childNodes.length; i < len; i++) if(index == 0)
if(_itemTypeMenu.firstChild.childNodes[i].value == _itemBeingEdited.getType())
_itemTypeMenu.selectedIndex = i;
var fieldNames = new Array("title","dateAdded","dateModified");
var fields = Scholar.ItemFields.getItemTypeFields(_itemBeingEdited.getField("itemTypeID"));
for(var i = 0; i<fields.length; i++)
fieldNames.push(Scholar.ItemFields.getName(fields[i]));
for(var i = 0; i<fieldNames.length; i++)
{ {
var editable = (!_itemBeingEdited.isPrimaryField(fieldNames[i]) || _itemBeingEdited.isEditableField(fieldNames[i])); Scholar.debug('loading FIELDS');
while(_dynamicFields.hasChildNodes())
var valueElement = createValueElement(_itemBeingEdited.getField(fieldNames[i]), editable ? fieldNames[i] : null); _dynamicFields.removeChild(_dynamicFields.firstChild);
var label = document.createElement("label");
label.setAttribute("value",Scholar.getString("itemFields."+fieldNames[i])+":");
label.setAttribute("onclick","this.nextSibling.blur();");
addDynamicRow(label,valueElement);
}
//CREATORS: for(var i = 0, len = _itemTypeMenu.firstChild.childNodes.length; i < len; i++)
_beforeRow = _dynamicFields.firstChild.nextSibling; if(_itemTypeMenu.firstChild.childNodes[i].value == _itemBeingEdited.getType())
_creatorCount = 0; _itemTypeMenu.selectedIndex = i;
if(_itemBeingEdited.numCreators() > 0)
{ var fieldNames = new Array("title","dateAdded","dateModified");
for(var i = 0, len=_itemBeingEdited.numCreators(); i<len; i++) var fields = Scholar.ItemFields.getItemTypeFields(_itemBeingEdited.getField("itemTypeID"));
for(var i = 0; i<fields.length; i++)
fieldNames.push(Scholar.ItemFields.getName(fields[i]));
for(var i = 0; i<fieldNames.length; i++)
{ {
var creator = _itemBeingEdited.getCreator(i); var editable = (!_itemBeingEdited.isPrimaryField(fieldNames[i]) || _itemBeingEdited.isEditableField(fieldNames[i]));
addCreatorRow(creator['firstName'], creator['lastName'], creator['creatorTypeID']);
var valueElement = createValueElement(_itemBeingEdited.getField(fieldNames[i]), editable ? fieldNames[i] : null);
var label = document.createElement("label");
label.setAttribute("value",Scholar.getString("itemFields."+fieldNames[i])+":");
label.setAttribute("onclick","this.nextSibling.blur();");
addDynamicRow(label,valueElement);
}
//CREATORS:
_beforeRow = _dynamicFields.firstChild.nextSibling;
_creatorCount = 0;
if(_itemBeingEdited.numCreators() > 0)
{
for(var i = 0, len=_itemBeingEdited.numCreators(); i<len; i++)
{
var creator = _itemBeingEdited.getCreator(i);
addCreatorRow(creator['firstName'], creator['lastName'], creator['creatorTypeID']);
}
}
else
{
addCreatorRow('', '', 1);
} }
} }
else else if(index == 1)
{ {
addCreatorRow('', '', 1); Scholar.debug('loading NOTES');
} //NOTES:
while(_notesList.hasChildNodes())
//NOTES: _notesList.removeChild(_notesList.firstChild);
while(_notesList.hasChildNodes())
_notesList.removeChild(_notesList.firstChild);
var notes = Scholar.Items.get(_itemBeingEdited.getNotes()); var notes = Scholar.Items.get(_itemBeingEdited.getNotes());
if(notes.length) if(notes.length)
{
for(var i = 0; i < notes.length; i++)
{ {
var icon = document.createElement('image'); for(var i = 0; i < notes.length; i++)
icon.setAttribute('src','chrome://scholar/skin/treeitem-note.png'); {
var icon = document.createElement('image');
icon.setAttribute('src','chrome://scholar/skin/treeitem-note.png');
var label = document.createElement('label'); var label = document.createElement('label');
label.setAttribute('value',_noteToTitle(notes[i].getNote())); label.setAttribute('value',_noteToTitle(notes[i].getNote()));
label.setAttribute('crop','end'); label.setAttribute('crop','end');
var box = document.createElement('box'); var box = document.createElement('box');
box.setAttribute('onclick',"ScholarPane.openNoteWindow("+notes[i].getID()+");"); box.setAttribute('onclick',"ScholarPane.openNoteWindow("+notes[i].getID()+");");
box.setAttribute('class','clicky'); box.setAttribute('class','clicky');
box.appendChild(icon); box.appendChild(icon);
box.appendChild(label); box.appendChild(label);
var removeButton = document.createElement('label'); var removeButton = document.createElement('label');
removeButton.setAttribute("value","-"); removeButton.setAttribute("value","-");
removeButton.setAttribute("class","clicky"); removeButton.setAttribute("class","clicky");
removeButton.setAttribute("onclick","ScholarItemPane.removeNote("+notes[i].getID()+")"); removeButton.setAttribute("onclick","ScholarItemPane.removeNote("+notes[i].getID()+")");
var row = document.createElement('row'); var row = document.createElement('row');
row.appendChild(box); row.appendChild(box);
row.appendChild(removeButton); row.appendChild(removeButton);
_notesList.appendChild(row); _notesList.appendChild(row);
}
} }
_updateNoteCount();
}
else if(index == 2)
{
Scholar.debug('loading FILES');
//FILES
}
else if(index == 3)
{
Scholar.debug('loading TAGS');
//TAGS:
_tagsBox.item = _itemBeingEdited;
}
else if(index == 4)
{
Scholar.debug('loading RELATED');
//RELATED
_relatedBox.item = _itemBeingEdited;
} }
_updateNoteCount();
//TAGS:
_linksBox.item = _itemBeingEdited;
} }
function changeTypeTo(id) function changeTypeTo(id)

View file

@ -5,13 +5,7 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="itemPane.js"/> <script src="itemPane.js"/>
<tabbox id="scholar-view-item" flex="1"> <deck id="scholar-view-item" flex="1" onselect="ScholarItemPane.loadPane(this.selectedIndex);">
<tabs>
<tab label="&tabs.info.label;"/>
<tab label="&tabs.notes.label;"/>
<tab label="&tabs.files.label;"/>
</tabs>
<tabpanels flex="1">
<vbox id="scholar-info" flex="1"> <vbox id="scholar-info" flex="1">
<popupset> <popupset>
<popup id="creatorTypeMenu" position="after_start" oncommand="ScholarItemPane.modifyCreator(document.popupNode.getAttribute('fieldname').split('-')[1],'typeID',event.explicitOriginalTarget.getAttribute('typeid'));"/> <popup id="creatorTypeMenu" position="after_start" oncommand="ScholarItemPane.modifyCreator(document.popupNode.getAttribute('fieldname').split('-')[1],'typeID',event.explicitOriginalTarget.getAttribute('typeid'));"/>
@ -43,9 +37,7 @@
<vbox align="center" pack="center"> <vbox align="center" pack="center">
<label value="Coming soon"/> <label value="Coming soon"/>
</vbox> </vbox>
</tabpanels> <tagsbox id="editpane-tags" flex="1"/>
<hbox> <seealsobox id="editpane-related" flex="1"/>
<linksbox id="editpane-links" flex="1"/> </deck>
</hbox>
</tabbox>
</overlay> </overlay>

View file

@ -33,10 +33,6 @@ var ScholarPane = new function()
*/ */
function onLoad() function onLoad()
{ {
//Initialize collections view
collectionsView = new Scholar.CollectionTreeView();
document.getElementById('collections-tree').view = collectionsView;
if(Scholar.Prefs.get("scholarPaneOnTop")) if(Scholar.Prefs.get("scholarPaneOnTop"))
{ {
var oldPane = document.getElementById('scholar-pane'); var oldPane = document.getElementById('scholar-pane');
@ -61,6 +57,10 @@ var ScholarPane = new function()
appContent.insertBefore(newSplitter, document.getElementById('content')); appContent.insertBefore(newSplitter, document.getElementById('content'));
} }
//Initialize collections view
collectionsView = new Scholar.CollectionTreeView();
document.getElementById('collections-tree').view = collectionsView;
//Create the add menu with each item type //Create the add menu with each item type
var addMenu = document.getElementById('tb-add').firstChild; var addMenu = document.getElementById('tb-add').firstChild;
var itemTypes = Scholar.ItemTypes.getTypes(); var itemTypes = Scholar.ItemTypes.getTypes();
@ -167,16 +167,19 @@ var ScholarPane = new function()
noteEditor.note = item.ref; noteEditor.note = item.ref;
document.getElementById('scholar-view-note').lastChild.setAttribute('noteID',item.ref.getID()); document.getElementById('scholar-view-note').lastChild.setAttribute('noteID',item.ref.getID());
document.getElementById('item-pane').selectedIndex = 2; document.getElementById('item-pane').selectedIndex = 2;
document.getElementById('scholar-view-tabs').setAttribute('hidden',true);
} }
else else
{ {
ScholarItemPane.viewItem(item.ref); ScholarItemPane.viewItem(item.ref);
document.getElementById('item-pane').selectedIndex = 1; document.getElementById('item-pane').selectedIndex = 1;
document.getElementById('scholar-view-tabs').setAttribute('hidden',false);
} }
} }
else else
{ {
document.getElementById('item-pane').selectedIndex = 0; document.getElementById('item-pane').selectedIndex = 0;
document.getElementById('scholar-view-tabs').setAttribute('hidden',true);
var label = document.getElementById('scholar-view-selected-label'); var label = document.getElementById('scholar-view-selected-label');

View file

@ -23,7 +23,7 @@
<vbox id="appcontent"> <vbox id="appcontent">
<!-- Changes to attributes of scholar-splitter and scholar-pane must be mirrored on overlay.js's onLoad() function --> <!-- 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"/> <splitter id="scholar-splitter" resizebefore="closest" resizeafter="closest" collapsed="true"/>
<hbox id="scholar-pane" collapsed="true" flex="1"> <hbox id="scholar-pane" persist="height" collapsed="true">
<popupset> <popupset>
<popup id="scholar-collectionmenu" onpopupshowing="ScholarPane.buildCollectionContextMenu();"> <popup id="scholar-collectionmenu" onpopupshowing="ScholarPane.buildCollectionContextMenu();">
<menuitem label="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/> <menuitem label="&toolbar.newCollection.label;" command="cmd_scholar_newCollection"/>
@ -146,16 +146,27 @@
<toolbarbutton id="tb-fullscreen" label="Toggle Fullscreen" oncommand="ScholarPane.fullScreen();"/> <toolbarbutton id="tb-fullscreen" label="Toggle Fullscreen" oncommand="ScholarPane.fullScreen();"/>
<toolbarbutton class="tabs-closebutton" oncommand="ScholarPane.toggleDisplay()"/> <toolbarbutton class="tabs-closebutton" oncommand="ScholarPane.toggleDisplay()"/>
</toolbar> </toolbar>
<deck id="item-pane" selectedIndex="0" flex="1"> <groupbox flex="1">
<box pack="center" align="center"> <caption>
<label id="scholar-view-selected-label"/> <tabs id="scholar-view-tabs" onselect="document.getElementById('scholar-view-item').selectedIndex = this.selectedIndex;" hidden="true">
</box> <tab label="&tabs.info.label;"/>
<tabbox id="scholar-view-item" flex="1"/> <tab label="&tabs.notes.label;"/>
<vbox id="scholar-view-note" flex="1"> <tab label="&tabs.files.label;"/>
<noteeditor id="scholar-note-editor" flex="1"/> <tab label="&tabs.tags.label;"/>
<button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID'));"/> <tab label="&tabs.related.label;"/>
</vbox> </tabs>
</deck> </caption>
<deck id="item-pane" selectedIndex="0" flex="1">
<box pack="center" align="center">
<label id="scholar-view-selected-label"/>
</box>
<deck id="scholar-view-item" flex="1"/>
<vbox id="scholar-view-note" flex="1">
<noteeditor id="scholar-note-editor" flex="1"/>
<button label="Edit in a separate window" oncommand="ScholarPane.openNoteWindow(this.getAttribute('noteID'));"/>
</vbox>
</deck>
</groupbox>
</vbox> </vbox>
</hbox> </hbox>
</vbox> </vbox>

View file

@ -2,8 +2,9 @@
<!ENTITY tabs.info.label "Info"> <!ENTITY tabs.info.label "Info">
<!ENTITY tabs.notes.label "Notes"> <!ENTITY tabs.notes.label "Notes">
<!ENTITY tabs.tags.label "Tags">
<!ENTITY tabs.files.label "Files"> <!ENTITY tabs.files.label "Files">
<!ENTITY tabs.tags.label "Tags">
<!ENTITY tabs.related.label "Related">
<!ENTITY scholar.minus "-"> <!ENTITY scholar.minus "-">
<!ENTITY scholar.plus "+"> <!ENTITY scholar.plus "+">

View file

@ -97,7 +97,6 @@
#scholar-view-item vbox #scholar-view-item vbox
{ {
overflow: auto; overflow: auto;
background: #f5f5f5;
} }
#editpane-dynamic-fields row > label:first-child #editpane-dynamic-fields row > label:first-child