Closes #125, Separate customControls.xml into multiple files
This commit is contained in:
parent
dd4bc6f5e8
commit
b9f577da91
177
chrome/chromeFiles/content/scholar/bindings/noteeditor.xml
Normal file
177
chrome/chromeFiles/content/scholar/bindings/noteeditor.xml
Normal file
|
@ -0,0 +1,177 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<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[
|
||||||
|
this.noteRef = val;
|
||||||
|
|
||||||
|
if(this.note.getNoteSource())
|
||||||
|
this.item = Scholar.Items.get(this.note.getNoteSource());
|
||||||
|
|
||||||
|
this.id('noteField').setAttribute('value',this.note.getNote());
|
||||||
|
this.id('links').item = this.note;
|
||||||
|
]]>
|
||||||
|
</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[
|
||||||
|
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 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>
|
||||||
|
<xul:popup id="tagsPopup" width="300" onpopupshowing="this.firstChild.reload();">
|
||||||
|
<xul:tagsbox id="tags" flex="1"/>
|
||||||
|
</xul:popup>
|
||||||
|
</xul:popupset>
|
||||||
|
</xul:vbox>
|
||||||
|
</content>
|
||||||
|
</binding>
|
||||||
|
</bindings>
|
157
chrome/chromeFiles/content/scholar/bindings/relatedbox.xml
Normal file
157
chrome/chromeFiles/content/scholar/bindings/relatedbox.xml
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<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="seealso-box">
|
||||||
|
<implementation>
|
||||||
|
<field name="itemRef"/>
|
||||||
|
<property name="item" onget="return this.itemRef;">
|
||||||
|
<setter>
|
||||||
|
<![CDATA[
|
||||||
|
this.itemRef = val;
|
||||||
|
this.reload();
|
||||||
|
]]>
|
||||||
|
</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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</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:hbox align="center">
|
||||||
|
<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 id="seeAlsoRows"/>
|
||||||
|
</xul:grid>
|
||||||
|
</xul:vbox>
|
||||||
|
</content>
|
||||||
|
</binding>
|
||||||
|
</bindings>
|
153
chrome/chromeFiles/content/scholar/bindings/tagsbox.xml
Normal file
153
chrome/chromeFiles/content/scholar/bindings/tagsbox.xml
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<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="tags-box">
|
||||||
|
<implementation>
|
||||||
|
<field name="itemRef"/>
|
||||||
|
<property name="item" onget="return this.itemRef;">
|
||||||
|
<setter>
|
||||||
|
<![CDATA[
|
||||||
|
this.itemRef = val;
|
||||||
|
this.reload();
|
||||||
|
]]>
|
||||||
|
</setter>
|
||||||
|
</property>
|
||||||
|
<property name="summary">
|
||||||
|
<getter>
|
||||||
|
<![CDATA[
|
||||||
|
var r = "";
|
||||||
|
|
||||||
|
if(this.item)
|
||||||
|
{
|
||||||
|
var tags = this.item.getTags();
|
||||||
|
if(tags)
|
||||||
|
{
|
||||||
|
for(var i = 0; i < tags.length; i++)
|
||||||
|
{
|
||||||
|
r = r + tags[i] + ", ";
|
||||||
|
}
|
||||||
|
r = r.substr(0,r.length-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
]]>
|
||||||
|
</getter>
|
||||||
|
</property>
|
||||||
|
<method name="reload">
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var rows = this.id('tagRows');
|
||||||
|
while(rows.hasChildNodes())
|
||||||
|
rows.removeChild(rows.firstChild);
|
||||||
|
|
||||||
|
if(this.item)
|
||||||
|
{
|
||||||
|
var tags = this.item.getTags();
|
||||||
|
|
||||||
|
if(tags)
|
||||||
|
{
|
||||||
|
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 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);
|
||||||
|
row.setAttribute('id','tag-'+id);
|
||||||
|
|
||||||
|
rows.appendChild(row);
|
||||||
|
}
|
||||||
|
this.updateCount(tags.length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.updateCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
<method name="add">
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var t = prompt('Add Tag:');
|
||||||
|
if(t && this.item)
|
||||||
|
{
|
||||||
|
this.item.addTag(t);
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
<method name="remove">
|
||||||
|
<parameter name="id"/>
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
if(id)
|
||||||
|
{
|
||||||
|
this.item.removeTag(id);
|
||||||
|
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>
|
||||||
|
</bindings>
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<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="timed-textarea" extends="chrome://global/content/bindings/textbox.xml#textarea">
|
||||||
|
<implementation>
|
||||||
|
<field name="_timer">null</field>
|
||||||
|
<property name="timeout"
|
||||||
|
onset="this.setAttribute('timeout', val); return val;"
|
||||||
|
onget="return parseInt(this.getAttribute('timeout')) || 0;"/>
|
||||||
|
<property name="value">
|
||||||
|
<getter>
|
||||||
|
return this.inputField.value;
|
||||||
|
</getter>
|
||||||
|
<setter>
|
||||||
|
<![CDATA[
|
||||||
|
this.inputField.value = val;
|
||||||
|
if (this._timer)
|
||||||
|
clearTimeout(this._timer);
|
||||||
|
return val;
|
||||||
|
]]>
|
||||||
|
</setter>
|
||||||
|
</property>
|
||||||
|
<method name="_fireCommand">
|
||||||
|
<parameter name="me"/>
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
me._timer = null;
|
||||||
|
me.doCommand();
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
</implementation>
|
||||||
|
<handlers>
|
||||||
|
<handler event="input">
|
||||||
|
<![CDATA[
|
||||||
|
if (this._timer)
|
||||||
|
clearTimeout(this._timer);
|
||||||
|
this._timer = this.timeout && setTimeout(this._fireCommand, this.timeout, this);
|
||||||
|
]]>
|
||||||
|
</handler>
|
||||||
|
</handlers>
|
||||||
|
</binding>
|
||||||
|
</bindings>
|
|
@ -1,515 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<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="timed-textarea" extends="chrome://global/content/bindings/textbox.xml#textarea">
|
|
||||||
<implementation>
|
|
||||||
<field name="_timer">null</field>
|
|
||||||
<property name="timeout"
|
|
||||||
onset="this.setAttribute('timeout', val); return val;"
|
|
||||||
onget="return parseInt(this.getAttribute('timeout')) || 0;"/>
|
|
||||||
<property name="value">
|
|
||||||
<getter>
|
|
||||||
return this.inputField.value;
|
|
||||||
</getter>
|
|
||||||
<setter>
|
|
||||||
<![CDATA[
|
|
||||||
this.inputField.value = val;
|
|
||||||
if (this._timer)
|
|
||||||
clearTimeout(this._timer);
|
|
||||||
return val;
|
|
||||||
]]>
|
|
||||||
</setter>
|
|
||||||
</property>
|
|
||||||
<method name="_fireCommand">
|
|
||||||
<parameter name="me"/>
|
|
||||||
<body>
|
|
||||||
<![CDATA[
|
|
||||||
me._timer = null;
|
|
||||||
me.doCommand();
|
|
||||||
]]>
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
</implementation>
|
|
||||||
<handlers>
|
|
||||||
<handler event="input">
|
|
||||||
<![CDATA[
|
|
||||||
if (this._timer)
|
|
||||||
clearTimeout(this._timer);
|
|
||||||
this._timer = this.timeout && setTimeout(this._fireCommand, this.timeout, this);
|
|
||||||
]]>
|
|
||||||
</handler>
|
|
||||||
</handlers>
|
|
||||||
</binding>
|
|
||||||
<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[
|
|
||||||
this.noteRef = val;
|
|
||||||
|
|
||||||
if(this.note.getNoteSource())
|
|
||||||
this.item = Scholar.Items.get(this.note.getNoteSource());
|
|
||||||
|
|
||||||
this.id('noteField').setAttribute('value',this.note.getNote());
|
|
||||||
this.id('links').item = this.note;
|
|
||||||
]]>
|
|
||||||
</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[
|
|
||||||
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 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>
|
|
||||||
<xul:popup id="tagsPopup" width="300" onpopupshowing="this.firstChild.reload();">
|
|
||||||
<xul:tagsbox id="tags" flex="1"/>
|
|
||||||
</xul:popup>
|
|
||||||
</xul:popupset>
|
|
||||||
</xul:vbox>
|
|
||||||
</content>
|
|
||||||
</binding>
|
|
||||||
<binding id="tags-box">
|
|
||||||
<implementation>
|
|
||||||
<field name="itemRef"/>
|
|
||||||
<property name="item" onget="return this.itemRef;">
|
|
||||||
<setter>
|
|
||||||
<![CDATA[
|
|
||||||
this.itemRef = val;
|
|
||||||
this.reload();
|
|
||||||
]]>
|
|
||||||
</setter>
|
|
||||||
</property>
|
|
||||||
<property name="summary">
|
|
||||||
<getter>
|
|
||||||
<![CDATA[
|
|
||||||
var r = "";
|
|
||||||
|
|
||||||
if(this.item)
|
|
||||||
{
|
|
||||||
var tags = this.item.getTags();
|
|
||||||
if(tags)
|
|
||||||
{
|
|
||||||
for(var i = 0; i < tags.length; i++)
|
|
||||||
{
|
|
||||||
r = r + tags[i] + ", ";
|
|
||||||
}
|
|
||||||
r = r.substr(0,r.length-2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
|
||||||
]]>
|
|
||||||
</getter>
|
|
||||||
</property>
|
|
||||||
<method name="reload">
|
|
||||||
<body>
|
|
||||||
<![CDATA[
|
|
||||||
var rows = this.id('tagRows');
|
|
||||||
while(rows.hasChildNodes())
|
|
||||||
rows.removeChild(rows.firstChild);
|
|
||||||
|
|
||||||
if(this.item)
|
|
||||||
{
|
|
||||||
var tags = this.item.getTags();
|
|
||||||
|
|
||||||
if(tags)
|
|
||||||
{
|
|
||||||
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 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);
|
|
||||||
row.setAttribute('id','tag-'+id);
|
|
||||||
|
|
||||||
rows.appendChild(row);
|
|
||||||
}
|
|
||||||
this.updateCount(tags.length);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.updateCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
<method name="add">
|
|
||||||
<body>
|
|
||||||
<![CDATA[
|
|
||||||
var t = prompt('Add Tag:');
|
|
||||||
if(t && this.item)
|
|
||||||
{
|
|
||||||
this.item.addTag(t);
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</body>
|
|
||||||
</method>
|
|
||||||
<method name="remove">
|
|
||||||
<parameter name="id"/>
|
|
||||||
<body>
|
|
||||||
<![CDATA[
|
|
||||||
if(id)
|
|
||||||
{
|
|
||||||
this.item.removeTag(id);
|
|
||||||
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;
|
|
||||||
this.reload();
|
|
||||||
]]>
|
|
||||||
</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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]]>
|
|
||||||
</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:hbox align="center">
|
|
||||||
<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 id="seeAlsoRows"/>
|
|
||||||
</xul:grid>
|
|
||||||
</xul:vbox>
|
|
||||||
</content>
|
|
||||||
</binding>
|
|
||||||
</bindings>
|
|
|
@ -1,26 +1,26 @@
|
||||||
textbox[multiline="true"][type="timed"]
|
textbox[multiline="true"][type="timed"]
|
||||||
{
|
{
|
||||||
-moz-binding: url('chrome://scholar/content/customControls.xml#timed-textarea');
|
-moz-binding: url('chrome://scholar/content/bindings/timedtextarea.xml#timed-textarea');
|
||||||
}
|
}
|
||||||
|
|
||||||
noteeditor
|
noteeditor
|
||||||
{
|
{
|
||||||
-moz-binding: url('chrome://scholar/content/customControls.xml#note-editor');
|
-moz-binding: url('chrome://scholar/content/bindings/noteeditor.xml#note-editor');
|
||||||
}
|
|
||||||
|
|
||||||
tagsbox
|
|
||||||
{
|
|
||||||
-moz-binding: url('chrome://scholar/content/customControls.xml#tags-box');
|
|
||||||
}
|
|
||||||
|
|
||||||
seealsobox
|
|
||||||
{
|
|
||||||
-moz-binding: url('chrome://scholar/content/customControls.xml#seealso-box');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
linksbox
|
linksbox
|
||||||
{
|
{
|
||||||
-moz-binding: url('chrome://scholar/content/customControls.xml#links-box');
|
-moz-binding: url('chrome://scholar/content/bindings/noteeditor.xml#links-box');
|
||||||
|
}
|
||||||
|
|
||||||
|
tagsbox
|
||||||
|
{
|
||||||
|
-moz-binding: url('chrome://scholar/content/bindings/tagsbox.xml#tags-box');
|
||||||
|
}
|
||||||
|
|
||||||
|
seealsobox
|
||||||
|
{
|
||||||
|
-moz-binding: url('chrome://scholar/content/bindings/relatedbox.xml#seealso-box');
|
||||||
}
|
}
|
||||||
|
|
||||||
.clicky
|
.clicky
|
||||||
|
|
Loading…
Reference in New Issue
Block a user