RetroZilla/extensions/cck/browser/resources/content/cckwizard/ccklist.xml

140 lines
6.1 KiB
XML
Raw Normal View History

2015-10-21 05:03:22 +02:00
<?xml version="1.0"?>
<!DOCTYPE wizard SYSTEM "chrome://cckwizard/locale/cckWizard.dtd">
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="ccklist">
<content>
<xul:hbox flex="1">
<xul:vbox flex="1">
<xul:listbox flex="1">
</xul:listbox>
</xul:vbox>
<xul:vbox>
<xul:button label="&newButton.label;" accesskey="&newButton.accesskey;" type="new"/>
<xul:button label="&editButton.label;" accesskey="&editButton.accesskey;" type="edit"/>
<xul:button label="&deleteButton.label;" accesskey="&deleteButton.accesskey;" type="delete"/>
<xul:button label="&moveUpButton.label;" accesskey="&moveUpButton.accesskey;" type="moveup"/>
<xul:button label="&moveDownButton.label;" accesskey="&moveDownButton.accesskey;" type="movedown"/>
<xul:spacer flex="1"/>
</xul:vbox>
</xul:hbox>
</content>
<implementation>
<constructor>
this._enableDisableButtons();
</constructor>
<method name="clear">
<body>
<![CDATA[
var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];
while(listbox.getRowCount() != 0) {
listbox.removeItemAt(0);
}
]]>
</body>
</method>
<method name="getRowCount">
<body>
<![CDATA[
var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];
return listbox.getRowCount();
]]>
</body>
</method>
<method name="getItemAtIndex">
<parameter name="index"/>
<body>
<![CDATA[
var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];
return listbox.getItemAtIndex(index);
]]>
</body>
</method>
<method name="appendItem">
<parameter name="label"/>
<parameter name="value"/>
<body>
<![CDATA[
var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];
listboxitem = listbox.appendItem(label, value);
listboxitem.cck = new Array();
this._enableDisableButtons();
return listboxitem;
]]>
</body>
</method>
<method name="_enableDisableButtons">
<body>
var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];
if (listbox.selectedIndex == -1) {
document.getAnonymousNodes(this)[0].childNodes[1].childNodes[1].setAttribute("disabled","true");
document.getAnonymousNodes(this)[0].childNodes[1].childNodes[2].setAttribute("disabled","true");
document.getAnonymousNodes(this)[0].childNodes[1].childNodes[3].setAttribute("disabled","true");
document.getAnonymousNodes(this)[0].childNodes[1].childNodes[4].setAttribute("disabled","true");
} else {
document.getAnonymousNodes(this)[0].childNodes[1].childNodes[1].setAttribute("disabled","false");
document.getAnonymousNodes(this)[0].childNodes[1].childNodes[2].setAttribute("disabled","false");
document.getAnonymousNodes(this)[0].childNodes[1].childNodes[3].setAttribute("disabled","false");
document.getAnonymousNodes(this)[0].childNodes[1].childNodes[4].setAttribute("disabled","false");
if (listbox.selectedIndex == 0)
document.getAnonymousNodes(this)[0].childNodes[1].childNodes[3].setAttribute("disabled","true");
if (listbox.selectedIndex == listbox.getRowCount()-1)
document.getAnonymousNodes(this)[0].childNodes[1].childNodes[4].setAttribute("disabled","true");
}
</body>
</method>
<property name="selectedItem"
onget="return document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0].selectedItem;"
onset="document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0].selectedItem = val;"/>
</implementation>
<handlers>
<handler event="select">
this._enableDisableButtons();
</handler>
<handler event="dblclick">
if (event.originalTarget.tagName == "listitem")
eval(this.getAttribute("edit"));
</handler>
<handler event="command">
if (event.originalTarget.type == "delete") {
var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];
listbox.removeItemAt(listbox.selectedIndex);
} else if ((event.originalTarget.type == "moveup") || (event.originalTarget.type == "movedown")) {
var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];
var listitem=listbox.selectedItem;
var index;
if (event.originalTarget.type == "moveup")
index = listbox.selectedIndex-1;
else
index = listbox.selectedIndex+2;
var newlistitem;
if (index >= listbox.getRowCount()) {
newlistitem = listbox.appendItem(listitem.label , listitem.value);
} else {
newlistitem = listbox.insertItemAt(index, listitem.label , listitem.value);
}
newlistitem.cck = listitem.cck;
if (listitem.getAttribute("class") == "listitem-iconic") {
newlistitem.setAttribute("class", "listitem-iconic");
newlistitem.setAttribute("image", listitem.getAttribute("image"));
}
listbox.removeItemAt(listbox.selectedIndex);
listbox.selectItem(newlistitem);
} else {
eval(this.getAttribute(event.originalTarget.type));
}
eval(this.getAttribute("on" + event.originalTarget.type));
this._enableDisableButtons();
</handler>
<handler event="keypress" keycode="VK_DELETE">
if (event.originalTarget.tagName == "xul:listbox") {
var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];
listbox.removeItemAt(listbox.selectedIndex);
this._enableDisableButtons();
}
</handler>
</handlers>
</binding>
</bindings>