Fixes #24, tags for notes.
This is now a new control, <tagsbox> which is pretty darn portable.
This commit is contained in:
parent
7333a1b538
commit
1cdd1f3de2
|
@ -68,6 +68,8 @@
|
||||||
this.item = Scholar.Items.get(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].childNodes[1].setAttribute('value',this.note.getNote());
|
||||||
|
document.getAnonymousNodes(this)[0].lastChild.firstChild.item = this.note;
|
||||||
|
this.updateTagsSummary();
|
||||||
]]>
|
]]>
|
||||||
</setter>
|
</setter>
|
||||||
</property>
|
</property>
|
||||||
|
@ -98,6 +100,22 @@
|
||||||
]]>
|
]]>
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="updateTagsSummary">
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var popup = document.getAnonymousNodes(this)[0].lastChild;
|
||||||
|
var label = popup.previousSibling;
|
||||||
|
var v = popup.firstChild.summary;
|
||||||
|
|
||||||
|
if(!v || v == "")
|
||||||
|
v = "[click here]";
|
||||||
|
|
||||||
|
while(label.hasChildNodes())
|
||||||
|
label.removeChild(label.firstChild);
|
||||||
|
label.appendChild(document.createTextNode("Tags: " + v));
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
</implementation>
|
</implementation>
|
||||||
<handlers>
|
<handlers>
|
||||||
</handlers>
|
</handlers>
|
||||||
|
@ -106,7 +124,115 @@
|
||||||
<xul:label/>
|
<xul:label/>
|
||||||
<xul:textbox multiline="true" type="timed" timeout="1000" flex="1" oncommand="this.parentNode.parentNode.save();"/>
|
<xul:textbox multiline="true" type="timed" timeout="1000" flex="1" oncommand="this.parentNode.parentNode.save();"/>
|
||||||
<xul:label value="See also: (coming soon)"/>
|
<xul:label value="See also: (coming soon)"/>
|
||||||
<xul:label value="Tags: (coming soon)"/>
|
<xul:label onclick="this.nextSibling.showPopup(this,-1,-1,'popup',0,0);"/>
|
||||||
|
<xul:popup width="300" onpopuphidden="this.updateTagsSummary();">
|
||||||
|
<xul:tagsbox/>
|
||||||
|
</xul:popup>
|
||||||
|
</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.reloadTags();
|
||||||
|
]]>
|
||||||
|
</setter>
|
||||||
|
</property>
|
||||||
|
<property name="summary">
|
||||||
|
<getter>
|
||||||
|
<![CDATA[
|
||||||
|
var r = "";
|
||||||
|
|
||||||
|
if(this.item)
|
||||||
|
{
|
||||||
|
var tags = this.item.getTags();
|
||||||
|
for(var i = 0; i < tags.length; i++)
|
||||||
|
{
|
||||||
|
r = r + Scholar.Tags.getName(tags[i]) + ", ";
|
||||||
|
}
|
||||||
|
r = r.substr(0,r.length-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
]]>
|
||||||
|
</getter>
|
||||||
|
</property>
|
||||||
|
<method name="reloadTags">
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var rows = document.getAnonymousNodes(this)[0].lastChild.lastChild;
|
||||||
|
while(rows.hasChildNodes())
|
||||||
|
rows.removeChild(rows.firstChild);
|
||||||
|
|
||||||
|
if(this.item)
|
||||||
|
{
|
||||||
|
var tags = this.item.getTags();
|
||||||
|
|
||||||
|
for(var i = 0; i < tags.length; i++)
|
||||||
|
{
|
||||||
|
var icon= document.createElement("image");
|
||||||
|
icon.setAttribute('src','chrome://scholar/skin/tag.png');
|
||||||
|
|
||||||
|
var label = document.createElement("label");
|
||||||
|
label.setAttribute('value', Scholar.Tags.getName(tags[i]));
|
||||||
|
|
||||||
|
var remove = document.createElement("label");
|
||||||
|
remove.setAttribute('value','-');
|
||||||
|
remove.setAttribute('onclick',"this.parentNode.parentNode.parentNode.parentNode.parentNode.removeTag('"+tags[i]+"');");
|
||||||
|
remove.setAttribute('class','clicky');
|
||||||
|
|
||||||
|
var row = document.createElement("row");
|
||||||
|
row.appendChild(icon);
|
||||||
|
row.appendChild(label);
|
||||||
|
row.appendChild(remove);
|
||||||
|
|
||||||
|
rows.appendChild(row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
<method name="addTag">
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
t = prompt('Add Tag:');
|
||||||
|
if(t && this.item)
|
||||||
|
{
|
||||||
|
this.item.addTag(t);
|
||||||
|
this.reloadTags();
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
<method name="removeTag">
|
||||||
|
<parameter name="id"/>
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
if(id)
|
||||||
|
{
|
||||||
|
this.item.removeTag(id);
|
||||||
|
this.reloadTags();
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
</implementation>
|
||||||
|
<content>
|
||||||
|
<xul:vbox xbl:inherits="flex">
|
||||||
|
<xul:button label="Add Tag" oncommand="this.parentNode.parentNode.addTag();"/>
|
||||||
|
<xul:grid>
|
||||||
|
<xul:columns>
|
||||||
|
<xul:column/>
|
||||||
|
<xul:column flex="1"/>
|
||||||
|
<xul:column/>
|
||||||
|
</xul:columns>
|
||||||
|
<xul:rows/>
|
||||||
|
</xul:grid>
|
||||||
</xul:vbox>
|
</xul:vbox>
|
||||||
</content>
|
</content>
|
||||||
</binding>
|
</binding>
|
||||||
|
|
|
@ -22,8 +22,6 @@ ScholarItemPane = new function()
|
||||||
this.modifyCreator = modifyCreator;
|
this.modifyCreator = modifyCreator;
|
||||||
this.removeNote = removeNote;
|
this.removeNote = removeNote;
|
||||||
this.addNote = addNote;
|
this.addNote = addNote;
|
||||||
this.removeTag = removeTag;
|
|
||||||
this.addTag = addTag;
|
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
{
|
{
|
||||||
|
@ -147,34 +145,7 @@ ScholarItemPane = new function()
|
||||||
_updateNoteCount();
|
_updateNoteCount();
|
||||||
|
|
||||||
//TAGS:
|
//TAGS:
|
||||||
while(_tagsList.hasChildNodes())
|
_tagsList.item = _itemBeingEdited;
|
||||||
_tagsList.removeChild(_tagsList.firstChild);
|
|
||||||
|
|
||||||
var tags = _itemBeingEdited.getTags();
|
|
||||||
if(tags.length)
|
|
||||||
{
|
|
||||||
for(var i = 0; i < tags.length; i++)
|
|
||||||
{
|
|
||||||
var icon = document.createElement('image');
|
|
||||||
icon.setAttribute('src','chrome://scholar/skin/tag.png');
|
|
||||||
|
|
||||||
var label = document.createElement('label');
|
|
||||||
label.setAttribute('value',Scholar.Tags.getName(tags[i]));
|
|
||||||
label.setAttribute('crop','end');
|
|
||||||
|
|
||||||
var removeButton = document.createElement('label');
|
|
||||||
removeButton.setAttribute("value","-");
|
|
||||||
removeButton.setAttribute("class","clicky");
|
|
||||||
removeButton.setAttribute("onclick","ScholarItemPane.removeTag("+tags[i]+")");
|
|
||||||
|
|
||||||
var row = document.createElement('row');
|
|
||||||
row.appendChild(icon);
|
|
||||||
row.appendChild(label);
|
|
||||||
row.appendChild(removeButton);
|
|
||||||
|
|
||||||
_tagsList.appendChild(row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeTypeTo(id)
|
function changeTypeTo(id)
|
||||||
|
@ -387,18 +358,6 @@ ScholarItemPane = new function()
|
||||||
|
|
||||||
_notesLabel.value = Scholar.getString('pane.item.notes.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
|
_notesLabel.value = Scholar.getString('pane.item.notes.count.'+(c != 1 ? "plural" : "singular")).replace('%1',c) + ":";
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeTag(id)
|
|
||||||
{
|
|
||||||
_itemBeingEdited.removeTag(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addTag()
|
|
||||||
{
|
|
||||||
var t = prompt("Add Tag:");
|
|
||||||
if(t)
|
|
||||||
_itemBeingEdited.addTag(t);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addEventListener("load", function(e) { ScholarItemPane.onLoad(e); }, false);
|
addEventListener("load", function(e) { ScholarItemPane.onLoad(e); }, false);
|
||||||
|
|
|
@ -42,18 +42,7 @@
|
||||||
</grid>
|
</grid>
|
||||||
</vbox>
|
</vbox>
|
||||||
<vbox flex="1">
|
<vbox flex="1">
|
||||||
<hbox align="center">
|
<tagsbox id="editpane-dynamic-tags" flex="1"/>
|
||||||
<label id="editpane-tags-label"/>
|
|
||||||
<button label="Add Tag" oncommand="ScholarItemPane.addTag();"/>
|
|
||||||
</hbox>
|
|
||||||
<grid flex="1">
|
|
||||||
<columns>
|
|
||||||
<column/>
|
|
||||||
<column flex="1"/>
|
|
||||||
<column/>
|
|
||||||
</columns>
|
|
||||||
<rows id="editpane-dynamic-tags" flex="1"/>
|
|
||||||
</grid>
|
|
||||||
</vbox>
|
</vbox>
|
||||||
<vbox align="center" pack="center">
|
<vbox align="center" pack="center">
|
||||||
<label value="Coming soon"/>
|
<label value="Coming soon"/>
|
||||||
|
|
|
@ -8,6 +8,12 @@ noteeditor
|
||||||
-moz-binding: url('chrome://scholar/content/customControls.xml#note-editor');
|
-moz-binding: url('chrome://scholar/content/customControls.xml#note-editor');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tagsbox
|
||||||
|
{
|
||||||
|
-moz-binding: url('chrome://scholar/content/customControls.xml#tags-box');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#scholar-progress-box
|
#scholar-progress-box
|
||||||
{
|
{
|
||||||
border: 2px solid #7a0000;
|
border: 2px solid #7a0000;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user