Import from 1.9a8 tarball
[mozilla-extra.git] / extensions / cck / browser / resources / content / cckwizard / ccklist.xml
blob3702e79edce2ed0f1346ee1292ac3144c720b841
1 <?xml version="1.0"?>\r
2 <!DOCTYPE wizard SYSTEM "chrome://cckwizard/locale/cckWizard.dtd">\r
3 <bindings xmlns="http://www.mozilla.org/xbl"\r
4          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">\r
5   <binding id="ccklist">\r
6     <content>\r
7       <xul:hbox flex="1">\r
8         <xul:vbox flex="1">\r
9           <xul:listbox flex="1">\r
10           </xul:listbox>\r
11         </xul:vbox>\r
12         <xul:vbox>\r
13           <xul:button label="&newButton.label;" accesskey="&newButton.accesskey;" type="new"/>\r
14           <xul:button label="&editButton.label;" accesskey="&editButton.accesskey;" type="edit"/>\r
15           <xul:button label="&deleteButton.label;" accesskey="&deleteButton.accesskey;" type="delete"/>\r
16           <xul:button label="&moveUpButton.label;" accesskey="&moveUpButton.accesskey;" type="moveup"/>\r
17           <xul:button label="&moveDownButton.label;" accesskey="&moveDownButton.accesskey;" type="movedown"/>\r
18           <xul:spacer flex="1"/>\r
19         </xul:vbox>\r
20         </xul:hbox>\r
21     </content>\r
22     <implementation>\r
23       <constructor>\r
24         this._enableDisableButtons();\r
25       </constructor>\r
26       <method name="clear">\r
27         <body>\r
28           <![CDATA[\r
29             var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];\r
30             while(listbox.getRowCount() != 0) {\r
31               listbox.removeItemAt(0);\r
32             }\r
33           ]]>\r
34         </body>\r
35       </method>\r
36       <method name="getRowCount">\r
37         <body>\r
38           <![CDATA[\r
39             var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];\r
40             return listbox.getRowCount();\r
41           ]]>\r
42         </body>\r
43       </method>\r
44       <method name="getItemAtIndex">\r
45         <parameter name="index"/>      \r
46         <body>\r
47           <![CDATA[\r
48             var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];\r
49             return listbox.getItemAtIndex(index);\r
50           ]]>\r
51         </body>\r
52       </method>\r
53       <method name="appendItem">\r
54         <parameter name="label"/>\r
55         <parameter name="value"/>\r
56         <body>\r
57           <![CDATA[\r
58             var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];\r
59             listboxitem = listbox.appendItem(label, value);\r
60             listboxitem.cck = new Array();\r
61             this._enableDisableButtons();\r
62             return listboxitem;\r
63           ]]>\r
64         </body>\r
65       </method>\r
66       <method name="_enableDisableButtons">\r
67         <body>\r
68           var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];\r
69           if (listbox.selectedIndex == -1) {\r
70             document.getAnonymousNodes(this)[0].childNodes[1].childNodes[1].setAttribute("disabled","true");\r
71             document.getAnonymousNodes(this)[0].childNodes[1].childNodes[2].setAttribute("disabled","true");\r
72             document.getAnonymousNodes(this)[0].childNodes[1].childNodes[3].setAttribute("disabled","true");\r
73             document.getAnonymousNodes(this)[0].childNodes[1].childNodes[4].setAttribute("disabled","true");\r
74           } else {\r
75             document.getAnonymousNodes(this)[0].childNodes[1].childNodes[1].setAttribute("disabled","false");\r
76             document.getAnonymousNodes(this)[0].childNodes[1].childNodes[2].setAttribute("disabled","false");\r
77             document.getAnonymousNodes(this)[0].childNodes[1].childNodes[3].setAttribute("disabled","false");\r
78             document.getAnonymousNodes(this)[0].childNodes[1].childNodes[4].setAttribute("disabled","false");\r
79             if (listbox.selectedIndex == 0)\r
80               document.getAnonymousNodes(this)[0].childNodes[1].childNodes[3].setAttribute("disabled","true");\r
81             if (listbox.selectedIndex == listbox.getRowCount()-1)\r
82               document.getAnonymousNodes(this)[0].childNodes[1].childNodes[4].setAttribute("disabled","true");\r
83         }\r
84         </body>\r
85       </method>\r
86       <property name="selectedItem"\r
87           onget="return document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0].selectedItem;"\r
88           onset="document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0].selectedItem = val;"/>      \r
89     </implementation>\r
90     <handlers>\r
91       <handler event="select">\r
92         this._enableDisableButtons();\r
93       </handler>\r
94       <handler event="dblclick">\r
95         if (event.originalTarget.tagName == "listitem")\r
96           eval(this.getAttribute("edit"));      \r
97       </handler>\r
98       <handler event="command">\r
99         if (event.originalTarget.type == "delete") {\r
100             var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];\r
101             listbox.removeItemAt(listbox.selectedIndex);\r
102         } else if ((event.originalTarget.type == "moveup") || (event.originalTarget.type == "movedown")) {\r
103           var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];\r
104           var listitem=listbox.selectedItem;\r
105           var index;\r
106           if (event.originalTarget.type == "moveup")\r
107             index = listbox.selectedIndex-1;\r
108           else\r
109             index = listbox.selectedIndex+2;\r
110           var newlistitem;\r
111           if (index >= listbox.getRowCount()) {\r
112             newlistitem = listbox.appendItem(listitem.label , listitem.value);\r
113           } else {\r
114             newlistitem = listbox.insertItemAt(index, listitem.label , listitem.value);\r
115           }\r
116           newlistitem.cck = listitem.cck;\r
117           if (listitem.getAttribute("class") == "listitem-iconic") {\r
118             newlistitem.setAttribute("class", "listitem-iconic");\r
119             newlistitem.setAttribute("image", listitem.getAttribute("image"));\r
120           }\r
121           listbox.removeItemAt(listbox.selectedIndex);\r
122           listbox.selectItem(newlistitem);\r
123         } else {\r
124           eval(this.getAttribute(event.originalTarget.type));\r
125         }\r
126         eval(this.getAttribute("on" + event.originalTarget.type));      \r
127         this._enableDisableButtons();\r
128       </handler>\r
129       <handler event="keypress" keycode="VK_DELETE">\r
130         if (event.originalTarget.tagName == "xul:listbox") {\r
131           var listbox=document.getAnonymousNodes(this)[0].childNodes[0].childNodes[0];\r
132           listbox.removeItemAt(listbox.selectedIndex);\r
133           this._enableDisableButtons();\r
134         }\r
135       </handler>\r
136       \r
137     </handlers>\r
138   </binding>\r
139 </bindings>\r