]>
Commit | Line | Data |
---|---|---|
a3e2f1a9 | 1 | define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { |
d39a2f80 AD |
2 | |
3 | return declare("fox.PrefFeedTree", lib.CheckBoxTree, { | |
4 | _createTreeNode: function(args) { | |
5 | var tnode = this.inherited(arguments); | |
6 | ||
b3e3cb06 | 7 | var icon = dojo.doc.createElement('img'); |
8 | if (args.item.icon && args.item.icon[0]) { | |
6887a0f5 | 9 | icon.src = args.item.icon[0]; |
b3e3cb06 | 10 | } else { |
11 | icon.src = 'images/blank_icon.gif'; | |
6887a0f5 | 12 | } |
b3e3cb06 | 13 | icon.className = 'tinyFeedIcon'; |
14 | domConstruct.place(icon, tnode.iconNode, 'only'); | |
d39a2f80 AD |
15 | |
16 | var param = this.model.store.getValue(args.item, 'param'); | |
17 | ||
18 | if (param) { | |
19 | param = dojo.doc.createElement('span'); | |
20 | param.className = 'feedParam'; | |
21 | param.innerHTML = args.item.param[0]; | |
9f539be3 AK |
22 | //domConstruct.place(param, tnode.labelNode, 'after'); |
23 | domConstruct.place(param, tnode.rowNode, 'first'); | |
d39a2f80 AD |
24 | } |
25 | ||
26 | var id = args.item.id[0]; | |
27 | var bare_id = parseInt(id.substr(id.indexOf(':')+1)); | |
28 | ||
29 | if (id.match("CAT:") && bare_id > 0) { | |
30 | var menu = new dijit.Menu(); | |
31 | menu.row_id = bare_id; | |
32 | menu.item = args.item; | |
33 | ||
34 | menu.addChild(new dijit.MenuItem({ | |
35 | label: __("Edit category"), | |
36 | onClick: function() { | |
37 | editCat(this.getParent().row_id, this.getParent().item, null); | |
38 | }})); | |
39 | ||
40 | ||
41 | menu.addChild(new dijit.MenuItem({ | |
42 | label: __("Remove category"), | |
43 | onClick: function() { | |
44 | removeCategory(this.getParent().row_id, this.getParent().item); | |
45 | }})); | |
46 | ||
47 | menu.bindDomNode(tnode.domNode); | |
48 | tnode._menu = menu; | |
49 | } else if (id.match("FEED:")) { | |
50 | var menu = new dijit.Menu(); | |
51 | menu.row_id = bare_id; | |
52 | menu.item = args.item; | |
53 | ||
54 | menu.addChild(new dijit.MenuItem({ | |
55 | label: __("Edit feed"), | |
56 | onClick: function() { | |
57 | editFeed(this.getParent().row_id); | |
58 | }})); | |
59 | ||
60 | menu.addChild(new dijit.MenuItem({ | |
61 | label: __("Unsubscribe"), | |
62 | onClick: function() { | |
63 | unsubscribeFeed(this.getParent().row_id, this.getParent().item.name); | |
64 | }})); | |
65 | ||
66 | menu.bindDomNode(tnode.domNode); | |
67 | tnode._menu = menu; | |
68 | ||
69 | } | |
70 | ||
71 | return tnode; | |
72 | }, | |
73 | onDndDrop: function() { | |
74 | this.inherited(arguments); | |
75 | this.tree.model.store.save(); | |
76 | }, | |
77 | getRowClass: function (item, opened) { | |
78 | return (!item.error || item.error == '') ? "dijitTreeRow" : | |
79 | "dijitTreeRow Error"; | |
80 | }, | |
81 | getIconClass: function (item, opened) { | |
82 | return (!item || this.model.store.getValue(item, 'type') == 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon"; | |
83 | }, | |
84 | checkItemAcceptance: function(target, source, position) { | |
85 | var item = dijit.getEnclosingWidget(target).item; | |
86 | ||
87 | // disable copying items | |
88 | source.copyState = function() { return false; }; | |
89 | ||
90 | var source_item = false; | |
91 | ||
92 | source.forInSelectedItems(function(node) { | |
93 | source_item = node.data.item; | |
94 | }); | |
95 | ||
96 | if (!source_item || !item) return false; | |
97 | ||
98 | var id = this.tree.model.store.getValue(item, 'id'); | |
99 | var source_id = source.tree.model.store.getValue(source_item, 'id'); | |
100 | ||
101 | //console.log(id + " " + position + " " + source_id); | |
102 | ||
103 | if (source_id.match("FEED:")) { | |
104 | return ((id.match("CAT:") && position == "over") || | |
49c6c279 | 105 | (id.match("FEED:") && position != "over")); |
d39a2f80 AD |
106 | } else if (source_id.match("CAT:")) { |
107 | return ((id.match("CAT:") && !id.match("CAT:0")) || | |
49c6c279 | 108 | (id.match("root") && position == "over")); |
d39a2f80 AD |
109 | } |
110 | }, | |
111 | }); | |
2148e0d5 AD |
112 | }); |
113 |