www

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

commit 7103fd4f1d27b4532ca06ff95f2925578d4ed0e6
parent 8427ebdf2a064362d03b7c7649207ccc8734ef17
Author: David Norton <david@nortoncrew.com>
Date:   Thu, 20 Jul 2006 23:19:31 +0000

Fixes #23, "see also" part of note.

Also, metadata looks better. See Also and Tags and Items.

Diffstat:
Mchrome/chromeFiles/content/scholar/customControls.xml | 372++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
Mchrome/chromeFiles/content/scholar/itemPane.js | 8++++----
Mchrome/chromeFiles/content/scholar/itemPane.xul | 5+----
Achrome/chromeFiles/content/scholar/selectItemsDialog.js | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Achrome/chromeFiles/content/scholar/selectItemsDialog.xul | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mchrome/chromeFiles/skin/default/scholar/overlay.css | 6++++--
Mchrome/chromeFiles/skin/default/scholar/scholar.css | 24++++++++++++++++++++++++
7 files changed, 467 insertions(+), 62 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/customControls.xml b/chrome/chromeFiles/content/scholar/customControls.xml @@ -49,7 +49,7 @@ <![CDATA[ this.itemRef = val; - var citeLabel = document.getAnonymousNodes(this)[0].childNodes[0]; + var citeLabel = this.id('citeLabel'); if(citeLabel.firstChild) citeLabel.removeChild(citeLabel.firstChild); @@ -67,17 +67,16 @@ if(this.note.getNoteSource()) this.item = Scholar.Items.get(this.note.getNoteSource()); - document.getAnonymousNodes(this)[0].childNodes[1].setAttribute('value',this.note.getNote()); - document.getAnonymousNodes(this)[0].lastChild.firstChild.item = this.note; - this.updateTagsSummary(); + this.id('noteField').setAttribute('value',this.note.getNote()); + this.id('links').item = this.note; ]]> </setter> </property> - <property name="value" onget="return document.getAnonymousNodes(this)[0].childNodes[1].value;" onset="document.getAnonymousNodes(this)[0].childNodes[1].value = val;"/> + <property name="value" onget="return this.id('noteField').value;" onset="this.id('noteField').value = val;"/> <method name="save"> <body> <![CDATA[ - var noteField = document.getAnonymousNodes(this)[0].childNodes[1]; + var noteField = this.id('noteField'); if(this.note) //Update note { this.note.updateNote(noteField.value); @@ -96,38 +95,113 @@ <method name="focus"> <body> <![CDATA[ - document.getAnonymousNodes(this)[0].childNodes[1].focus(); + this.id('noteField').focus(); + ]]> + </body> + </method> + <method name="id"> + <parameter name="id"/> + <body> + <![CDATA[ + return document.getAnonymousNodes(this)[0].getElementsByAttribute('id',id)[0]; + ]]> + </body> + </method> + </implementation> + <handlers> + </handlers> + <content> + <xul:vbox xbl:inherits="flex"> + <xul:label id="citeLabel"/> + <xul:textbox id="noteField" multiline="true" type="timed" timeout="1000" flex="1" oncommand="this.parentNode.parentNode.save();"/> + <xul:hbox> + <xul:linksbox id="links" flex="1"/> + </xul:hbox> + </xul:vbox> + </content> + </binding> + <binding id="links-box"> + <implementation> + <field name="itemRef"/> + <property name="item" onget="return this.itemRef;"> + <setter> + <![CDATA[ + this.itemRef = val; + + this.id('tags').item = this.item; + this.updateTagsSummary(); + this.id('seeAlso').item = this.item; + this.updateSeeAlsoSummary(); + ]]> + </setter> + </property> + <method name="tagsClick"> + <body> + <![CDATA[ + var tagsList = this.item.getTags(); + if(tagsList && tagsList.length > 0) + this.id('tagsPopup').showPopup(this.id('tagsLabel'),-1,-1,-1,'popup',0,0); + else + this.id('tags').add(); ]]> </body> </method> <method name="updateTagsSummary"> <body> <![CDATA[ - var popup = document.getAnonymousNodes(this)[0].lastChild; - var label = popup.previousSibling; - var v = popup.firstChild.summary; + var v = this.id('tags').summary; if(!v || v == "") v = "[click here]"; - while(label.hasChildNodes()) - label.removeChild(label.firstChild); - label.appendChild(document.createTextNode("Tags: " + v)); + this.id('tagsLabel').value = "Tags: " + v; + ]]> + </body> + </method> + <method name="seeAlsoClick"> + <body> + <![CDATA[ + var seealsoList = this.item.getSeeAlso(); + if(seealsoList && seealsoList.length > 0) + this.id('seeAlsoPopup').showPopup(this.id('seeAlsoLabel'),-1,-1,'popup',0,0); + else + this.id('seeAlso').add(); + ]]> + </body> + </method> + <method name="updateSeeAlsoSummary"> + <body> + <![CDATA[ + var v = this.id('seeAlso').summary; + + if(!v || v == "") + v = "[click here]"; + + this.id('seeAlsoLabel').value = "Related: " + v; + ]]> + </body> + </method> + <method name="id"> + <parameter name="id"/> + <body> + <![CDATA[ + return document.getAnonymousNodes(this)[0].getElementsByAttribute('id',id)[0]; ]]> </body> </method> </implementation> - <handlers> - </handlers> <content> <xul:vbox xbl:inherits="flex"> - <xul:label/> - <xul:textbox multiline="true" type="timed" timeout="1000" flex="1" oncommand="this.parentNode.parentNode.save();"/> - <xul:label value="See also: (coming soon)"/> - <xul:label onclick="this.nextSibling.showPopup(this,-1,-1,'popup',0,0);"/> - <xul:popup width="300" onpopuphidden="this.parentNode.parentNode.updateTagsSummary();"> - <xul:tagsbox flex="1"/> - </xul:popup> + <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:popupset> + <xul:popup id="seeAlsoPopup" width="300" onpopupshowing="this.firstChild.reload();" onpopuphiding="this.parentNode.parentNode.parentNode.updateSeeAlsoSummary();"> + <xul:seealsobox id="seeAlso" flex="1"/> + </xul:popup> + <xul:popup id="tagsPopup" width="300" onpopupshowing="this.firstChild.reload();" onpopuphiding="this.parentNode.parentNode.parentNode.updateTagsSummary();"> + <xul:tagsbox id="tags" flex="1"/> + </xul:popup> + </xul:popupset> </xul:vbox> </content> </binding> @@ -138,8 +212,6 @@ <setter> <![CDATA[ this.itemRef = val; - - this.reloadTags(); ]]> </setter> </property> @@ -151,21 +223,24 @@ if(this.item) { var tags = this.item.getTags(); - for(var i = 0; i < tags.length; i++) + if(tags) { - r = r + tags[i] + ", "; + for(var i = 0; i < tags.length; i++) + { + r = r + tags[i] + ", "; + } + r = r.substr(0,r.length-2); } - r = r.substr(0,r.length-2); } return r; ]]> </getter> </property> - <method name="reloadTags"> + <method name="reload"> <body> <![CDATA[ - var rows = document.getAnonymousNodes(this)[0].lastChild.lastChild; + var rows = this.id('tagRows'); while(rows.hasChildNodes()) rows.removeChild(rows.firstChild); @@ -173,66 +248,259 @@ { var tags = this.item.getTags(); - for(var i = 0; i < tags.length; i++) + if(tags) { - var icon= document.createElement("image"); - icon.setAttribute('src','chrome://scholar/skin/tag.png'); + for(var i = 0; i < tags.length; i++) + { + var id = Scholar.Tags.getID(tags[i]); + + var icon= document.createElement("image"); + icon.setAttribute('src','chrome://scholar/skin/tag.png'); - var label = document.createElement("label"); - label.setAttribute('value', tags[i]); - label.setAttribute('crop','end'); + var label = document.createElement("label"); + label.setAttribute('value', tags[i]); + label.setAttribute('crop','end'); - var remove = document.createElement("label"); - remove.setAttribute('value','-'); - remove.setAttribute('onclick',"this.parentNode.parentNode.parentNode.parentNode.parentNode.removeTag('"+Scholar.Tags.getID(tags[i])+"');"); - remove.setAttribute('class','clicky'); + var remove = document.createElement("label"); + remove.setAttribute('value','-'); + remove.setAttribute('onclick',"this.parentNode.parentNode.parentNode.parentNode.parentNode.remove('"+id+"');"); + remove.setAttribute('class','clicky'); - var row = document.createElement("row"); - row.appendChild(icon); - row.appendChild(label); - row.appendChild(remove); + var row = document.createElement("row"); + row.appendChild(icon); + row.appendChild(label); + row.appendChild(remove); + row.setAttribute('id','tag-'+id); - rows.appendChild(row); - } + rows.appendChild(row); + } + this.updateCount(tags.length); + } + else + { + this.updateCount(); + } } ]]> </body> </method> - <method name="addTag"> + <method name="add"> <body> <![CDATA[ - t = prompt('Add Tag:'); + var t = prompt('Add Tag:'); if(t && this.item) { this.item.addTag(t); - this.reloadTags(); + this.parentNode.parentNode.parentNode.parentNode.updateTagsSummary(); } ]]> </body> </method> - <method name="removeTag"> + <method name="remove"> <parameter name="id"/> <body> <![CDATA[ if(id) { this.item.removeTag(id); - this.reloadTags(); + var rows = this.id('tagRows'); + rows.removeChild(this.id('tag-'+id)); + this.updateCount(); } ]]> </body> </method> + <method name="updateCount"> + <parameter name="count"/> + <body> + <![CDATA[ + if(count == null) + { + tags = this.item.getTags(); + if(tags) + count = tags.length; + else + count = 0; + } + + this.id('tagsNum').value = count + ' tags:'; + ]]> + </body> + </method> + <method name="id"> + <parameter name="id"/> + <body> + <![CDATA[ + return document.getAnonymousNodes(this)[0].getElementsByAttribute('id',id)[0]; + ]]> + </body> + </method> + </implementation> + <content> + <xul:vbox xbl:inherits="flex"> + <xul:hbox align="center"> + <xul:label id="tagsNum"/> + <xul:button label="Add" oncommand="this.parentNode.parentNode.parentNode.add();"/> + </xul:hbox> + <xul:grid> + <xul:columns> + <xul:column/> + <xul:column flex="1"/> + <xul:column/> + </xul:columns> + <xul:rows id="tagRows"/> + </xul:grid> + </xul:vbox> + </content> + </binding> + <binding id="seealso-box"> + <implementation> + <field name="itemRef"/> + <property name="item" onget="return this.itemRef;"> + <setter> + <![CDATA[ + this.itemRef = val; + ]]> + </setter> + </property> + <property name="summary"> + <getter> + <![CDATA[ + var r = ""; + + if(this.item) + { + var seealso = this.item.getSeeAlso(); + if(seealso) + { + seealso = Scholar.Items.get(seealso); + for(var i = 0; i < seealso.length; i++) + { + r = r + seealso[i].getField('title') + ", "; + } + r = r.substr(0,r.length-2); + } + } + + return r; + ]]> + </getter> + </property> + <method name="reload"> + <body> + <![CDATA[ + var rows = this.id('seeAlsoRows'); + while(rows.hasChildNodes()) + rows.removeChild(rows.firstChild); + + if(this.item) + { + var seealso = this.item.getSeeAlso(); + + if(seealso) + { + seealso = Scholar.Items.get(seealso); + for(var i = 0; i < seealso.length; i++) + { + var icon= document.createElement("image"); + icon.setAttribute('src','chrome://scholar/skin/treeitem-'+Scholar.ItemTypes.getName(seealso[i].getType())+'.png'); + + var label = document.createElement("label"); + label.setAttribute('value', seealso[i].getField('title')); + label.setAttribute('crop','end'); + + var remove = document.createElement("label"); + remove.setAttribute('value','-'); + remove.setAttribute('onclick',"this.parentNode.parentNode.parentNode.parentNode.parentNode.remove('"+seealso[i].getID()+"');"); + remove.setAttribute('class','clicky'); + + var row = document.createElement("row"); + row.appendChild(icon); + row.appendChild(label); + row.appendChild(remove); + row.setAttribute('id','seealso-'+seealso[i].getID()); + rows.appendChild(row); + } + this.updateCount(seealso.length); + } + else + { + this.updateCount(); + } + } + ]]> + </body> + </method> + <method name="add"> + <body> + <![CDATA[ + var io = {dataIn: null, dataOut: null}; + window.openDialog('chrome://scholar/content/selectItemsDialog.xul','','chrome,modal',io); + + if(io.dataOut && this.item) + { + for(var i = 0; i < io.dataOut.length; i++) + { + this.item.addSeeAlso(io.dataOut[i]); + } + this.parentNode.parentNode.parentNode.parentNode.updateSeeAlsoSummary(); + } + ]]> + </body> + </method> + <method name="remove"> + <parameter name="id"/> + <body> + <![CDATA[ + if(id) + { + this.item.removeSeeAlso(id); + var rows = this.id('seeAlsoRows'); + rows.removeChild(this.id('seealso-'+id)); + this.updateCount(); + } + ]]> + </body> + </method> + <method name="updateCount"> + <parameter name="count"/> + <body> + <![CDATA[ + if(count == null) + { + seealso = this.item.getSeeAlso(); + if(seealso) + count = seealso.length; + else + count = 0; + } + + this.id('seeAlsoNum').value = count + ' related:'; + ]]> + </body> + </method> + <method name="id"> + <parameter name="id"/> + <body> + <![CDATA[ + return document.getAnonymousNodes(this)[0].getElementsByAttribute('id',id)[0]; + ]]> + </body> + </method> </implementation> <content> <xul:vbox xbl:inherits="flex"> - <xul:button label="Add Tag" oncommand="this.parentNode.parentNode.addTag();"/> + <xul:hbox> + <xul:label id="seeAlsoNum"/> + <xul:button label="Add" oncommand="this.parentNode.parentNode.parentNode.add();"/> + </xul:hbox> <xul:grid> <xul:columns> <xul:column/> <xul:column flex="1"/> <xul:column/> </xul:columns> - <xul:rows/> + <xul:rows id="seeAlsoRows"/> </xul:grid> </xul:vbox> </content> diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js @@ -4,7 +4,7 @@ ScholarItemPane = new function() var _creatorTypeMenu; var _beforeRow; var _notesList; - var _tagsList; + var _linksBox; var _notesLabel; var _creatorCount; @@ -30,7 +30,7 @@ ScholarItemPane = new function() _creatorTypeMenu = document.getElementById('creatorTypeMenu'); _notesList = document.getElementById('editpane-dynamic-notes'); _notesLabel = document.getElementById('editpane-notes-label'); - _tagsList = document.getElementById('editpane-dynamic-tags'); + _linksBox = document.getElementById('editpane-links'); var creatorTypes = Scholar.CreatorTypes.getTypes(); for(var i = 0; i < creatorTypes.length; i++) @@ -142,7 +142,7 @@ ScholarItemPane = new function() _updateNoteCount(); //TAGS: - _tagsList.item = _itemBeingEdited; + _linksBox.item = _itemBeingEdited; } function changeTypeTo(id) @@ -156,7 +156,7 @@ ScholarItemPane = new function() } function addDynamicRow(label, value, beforeElement) - { + { var row = document.createElement("row"); row.appendChild(label); row.appendChild(value); diff --git a/chrome/chromeFiles/content/scholar/itemPane.xul b/chrome/chromeFiles/content/scholar/itemPane.xul @@ -9,7 +9,6 @@ <tabs> <tab label="&tabs.info.label;"/> <tab label="&tabs.notes.label;"/> - <tab label="&tabs.tags.label;"/> <tab label="&tabs.files.label;"/> </tabs> <tabpanels flex="1"> @@ -41,12 +40,10 @@ <rows id="editpane-dynamic-notes" flex="1"/> </grid> </vbox> - <vbox flex="1"> - <tagsbox id="editpane-dynamic-tags" flex="1"/> - </vbox> <vbox align="center" pack="center"> <label value="Coming soon"/> </vbox> </tabpanels> + <linksbox id="editpane-links"/> </tabbox> </overlay> \ No newline at end of file diff --git a/chrome/chromeFiles/content/scholar/selectItemsDialog.js b/chrome/chromeFiles/content/scholar/selectItemsDialog.js @@ -0,0 +1,48 @@ +var itemsView; +var collectionsView; +var io; + +function doLoad() +{ + io = window.arguments[0]; + + collectionsView = new Scholar.CollectionTreeView(); + document.getElementById('collections-tree').view = collectionsView; +} + +function onCollectionSelected() +{ + if(itemsView) + itemsView.unregister(); + + if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1) + { + var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex); + collection.setSearch(''); + + itemsView = new Scholar.ItemTreeView(collection); + document.getElementById('items-tree').view = itemsView; + } + +} + +function onItemSelected() +{ + +} + +function doAccept() +{ + var start = new Object(); + var end = new Object(); + io.dataOut = new Array(); + + for(var i = 0, rangeCount = itemsView.selection.getRangeCount(); i < rangeCount; i++) + { + itemsView.selection.getRangeAt(i,start,end); + for(var j = start.value; j <= end.value; j++) + { + io.dataOut.push(itemsView._getItemAtRow(j).ref.getID()); + } + } +} +\ No newline at end of file diff --git a/chrome/chromeFiles/content/scholar/selectItemsDialog.xul b/chrome/chromeFiles/content/scholar/selectItemsDialog.xul @@ -0,0 +1,65 @@ +<?xml version="1.0"?> +<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> +<?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"> + +<dialog + id="scholar-select-items-dialog" + title="Select" + orient="vertical" + width="600" height="450" + persist="width height screenX screenY" + buttons="cancel,accept" + ondialogaccept="doAccept();" + onload="doLoad();" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + style="padding:2em"> + + <script src="include.js"/> + <script src="collectionTreeView.js"/> + <script src="itemTreeView.js"/> + <script src="selectItemsDialog.js"/> + + <hbox flex="1"> + <tree id="collections-tree" + style="width: 200px;" hidecolumnpicker="true" seltype="single" + onselect="onCollectionSelected();"> + <treecols> + <treecol + id="name_column" + label="&collections.name_column;" + flex="1" + primary="true"/> + </treecols> + <treechildren/> + </tree> + + <tree id="items-tree" + flex="1" hidecolumnpicker="true" seltype="multiple" + onselect="onItemSelected();"> + <treecols> + <treecol + id="title" primary="true" + label="&items.title_column;" + flex="4" persist="width ordinal hidden sortActive sortDirection"/> + <splitter class="tree-splitter"/> + <treecol + id="firstCreator" + label="&items.creator_column;" + flex="1" persist="width ordinal hidden sortActive sortDirection"/> + <splitter class="tree-splitter"/> + <treecol + id="dateAdded" hidden="true" + label="&items.dateAdded_column;" + flex="1" persist="width ordinal hidden sortActive sortDirection"/> + <splitter class="tree-splitter"/> + <treecol + id="dateModified" hidden="true" + label="&items.dateModified_column;" + flex="1" persist="width ordinal hidden sortActive sortDirection"/> + </treecols> + <treechildren/> + </tree> + </hbox> +</dialog> diff --git a/chrome/chromeFiles/skin/default/scholar/overlay.css b/chrome/chromeFiles/skin/default/scholar/overlay.css @@ -97,11 +97,13 @@ #scholar-view-item vbox { overflow: auto; + background: #f5f5f5; } -#scholar-notes-menu +#editpane-dynamic-fields row > label:first-child { - -moz-user-focus: ignore; + text-align: right; + font-weight: bold; } #scholar-view-item diff --git a/chrome/chromeFiles/skin/default/scholar/scholar.css b/chrome/chromeFiles/skin/default/scholar/scholar.css @@ -13,11 +13,35 @@ tagsbox -moz-binding: url('chrome://scholar/content/customControls.xml#tags-box'); } +seealsobox +{ + -moz-binding: url('chrome://scholar/content/customControls.xml#seealso-box'); +} + +linksbox +{ + -moz-binding: url('chrome://scholar/content/customControls.xml#links-box'); +} + .clicky { -moz-border-radius: 6px; } +.clicky[value="-"] +{ + margin: 0px; + padding-left: 4px; + padding-right: 4px; +} + +.clicky[value="+"] +{ + margin: 0px; + padding-left: 4px; + padding-right: 4px; +} + .clicky:hover { color: white;