zotero/chrome/chromeFiles/content/scholar/bindings/noteeditor.xml

195 lines
No EOL
6 KiB
XML

<?xml version="1.0"?>
<!--
Zotero
Copyright (C) 2006 Center for History and New Media, George Mason University, Fairfax, VA
http://chnm.gmu.edu/
-->
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="note-editor">
<implementation>
<field name="itemRef"/>
<property name="item" onget="return this.itemRef;">
<setter>
<![CDATA[
this.itemRef = val;
var citeLabel = this.id('citeLabel');
if(citeLabel.firstChild)
citeLabel.removeChild(citeLabel.firstChild);
if(this.item)
citeLabel.appendChild(document.createTextNode(this.item.getField('title')));
]]>
</setter>
</property>
<field name="noteRef"/>
<property name="note" onget="return this.noteRef;">
<setter>
<![CDATA[
var scrollPos = this.id('noteField').inputField.scrollTop;
this.noteRef = val;
if(this.note.getSource())
this.item = Scholar.Items.get(this.note.getSource());
this.id('noteField').value = this.note.getNote();
this.id('links').item = this.note;
this.id('noteField').inputField.scrollTop = scrollPos;
]]>
</setter>
</property>
<field name="collectionRef"/>
<property name="collection" onget="return this.collectionRef;" onset="this.collectionRef = val;"/>
<property name="value" onget="return this.id('noteField').value;" onset="this.id('noteField').value = val;"/>
<method name="save">
<body>
<![CDATA[
var noteField = this.id('noteField');
if(this.note) //Update note
{
this.note.updateNote(noteField.value);
}
else //Create new note
{
if(this.item)
var noteID = Scholar.Notes.add(noteField.value,this.item.getID()); //attached to an item
else
{
//independent note
var noteID = Scholar.Notes.add(noteField.value);
if(this.collection)
this.collection.addItem(noteID);
}
this.note = Scholar.Items.get(noteID);
}
]]>
</body>
</method>
<method name="focus">
<body>
<![CDATA[
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[
this.id('tags').reload();
this.id('tagsPopup').showPopup(this.id('tagsLabel'),-1,-1,'popup');
]]>
</body>
</method>
<method name="updateTagsSummary">
<body>
<![CDATA[
// TODO: localize
var v = this.id('tags').summary;
if(!v || v == "")
v = "[click here]";
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>
<content>
<xul:vbox xbl:inherits="flex">
<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();">
<xul:seealsobox id="seeAlso" flex="1"/>
</xul:popup>
<!-- The onpopup* stuff is an ugly hack to keep track of when the
popup is open (and not the descendent autocomplete popup, which also
seems to get triggered by these events for reasons that are less than
clear) so that we can manually refresh the popup if it's open after
autocomplete is used to prevent it from becoming unresponsive
Note: Code in tagsbox.xml is dependent on the DOM path between the
tagsbox and tagsLabel above, so be sure to update fixPopup() if it changes
-->
<xul:popup id="tagsPopup" ignorekeys="true" width="300"
onpopupshown="if (!document.commandDispatcher.focusedElement || document.commandDispatcher.focusedElement.tagName=='xul:label'){ /* DEBUG: it would be nice to make this work -- if (this.firstChild.count==0){ this.firstChild.new(); } */ this.setAttribute('showing', 'true'); }"
onpopuphidden="if (!document.commandDispatcher.focusedElement || document.commandDispatcher.focusedElement.tagName=='xul:label'){ this.setAttribute('showing', 'false'); }">
<xul:tagsbox id="tags" flex="1"/>
</xul:popup>
</xul:popupset>
</xul:vbox>
</content>
</binding>
</bindings>