]>
Commit | Line | Data |
---|---|---|
2148e0d5 | 1 | dojo.provide("fox.PrefFeedTree"); |
7b8a143f | 2 | dojo.provide("fox.PrefFeedStore"); |
2148e0d5 AD |
3 | |
4 | dojo.require("lib.CheckBoxTree"); | |
df1c35f4 | 5 | dojo.require("dojo.data.ItemFileWriteStore"); |
2148e0d5 | 6 | |
7b8a143f | 7 | dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, { |
2a060a94 | 8 | |
7b8a143f AD |
9 | _saveEverything: function(saveCompleteCallback, saveFailedCallback, |
10 | newFileContentString) { | |
11 | ||
12 | dojo.xhrPost({ | |
13 | url: "backend.php", | |
f30ef1fa | 14 | content: {op: "pref-feeds", method: "savefeedorder", |
7b8a143f AD |
15 | payload: newFileContentString}, |
16 | error: saveFailedCallback, | |
17 | load: saveCompleteCallback}); | |
18 | }, | |
19 | ||
2a060a94 | 20 | }); |
7b8a143f | 21 | |
2148e0d5 | 22 | dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, { |
82aea978 AD |
23 | _createTreeNode: function(args) { |
24 | var tnode = this.inherited(arguments); | |
25 | ||
26 | if (args.item.icon) | |
27 | tnode.iconNode.src = args.item.icon[0]; | |
28 | ||
1644304f AD |
29 | var param = this.model.store.getValue(args.item, 'param'); |
30 | ||
31 | if (param) { | |
32 | param = dojo.doc.createElement('span'); | |
33 | param.className = 'feedParam'; | |
34 | param.innerHTML = args.item.param[0]; | |
35 | dojo.place(param, tnode.labelNode, 'after'); | |
36 | } | |
37 | ||
5ef071e0 AD |
38 | var id = args.item.id[0]; |
39 | var bare_id = parseInt(id.substr(id.indexOf(':')+1)); | |
40 | ||
41 | if (id.match("CAT:") && bare_id > 0) { | |
42 | var menu = new dijit.Menu(); | |
43 | menu.row_id = bare_id; | |
44 | menu.item = args.item; | |
45 | ||
46 | menu.addChild(new dijit.MenuItem({ | |
47 | label: __("Edit category"), | |
48 | onClick: function() { | |
49 | editCat(this.getParent().row_id, this.getParent().item, null); | |
50 | }})); | |
51 | ||
52 | ||
53 | menu.addChild(new dijit.MenuItem({ | |
54 | label: __("Remove category"), | |
55 | onClick: function() { | |
56 | removeCategory(this.getParent().row_id, this.getParent().item); | |
57 | }})); | |
58 | ||
59 | menu.bindDomNode(tnode.domNode); | |
60 | tnode._menu = menu; | |
61 | } else if (id.match("FEED:")) { | |
62 | var menu = new dijit.Menu(); | |
63 | menu.row_id = bare_id; | |
64 | menu.item = args.item; | |
65 | ||
66 | menu.addChild(new dijit.MenuItem({ | |
67 | label: __("Edit feed"), | |
68 | onClick: function() { | |
69 | editFeed(this.getParent().row_id); | |
70 | }})); | |
71 | ||
72 | menu.addChild(new dijit.MenuItem({ | |
73 | label: __("Unsubscribe"), | |
74 | onClick: function() { | |
75 | unsubscribeFeed(this.getParent().row_id, this.getParent().item.name); | |
76 | }})); | |
77 | ||
78 | menu.bindDomNode(tnode.domNode); | |
79 | tnode._menu = menu; | |
80 | ||
81 | } | |
82 | ||
82aea978 AD |
83 | return tnode; |
84 | }, | |
7b8a143f AD |
85 | onDndDrop: function() { |
86 | this.inherited(arguments); | |
87 | this.tree.model.store.save(); | |
88 | }, | |
82aea978 | 89 | getRowClass: function (item, opened) { |
2a060a94 | 90 | return (!item.error || item.error == '') ? "dijitTreeRow" : |
82aea978 AD |
91 | "dijitTreeRow Error"; |
92 | }, | |
93 | getIconClass: function (item, opened) { | |
e8c20f92 | 94 | return (!item || this.model.store.getValue(item, 'type') == 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon"; |
82aea978 | 95 | }, |
2148e0d5 AD |
96 | checkItemAcceptance: function(target, source, position) { |
97 | var item = dijit.getEnclosingWidget(target).item; | |
98 | ||
49c6c279 | 99 | // disable copying items |
e331188f | 100 | source.copyState = function() { return false; }; |
49c6c279 AD |
101 | |
102 | var source_item = false; | |
103 | ||
104 | source.forInSelectedItems(function(node) { | |
105 | source_item = node.data.item; | |
106 | }); | |
107 | ||
108 | if (!source_item || !item) return false; | |
109 | ||
49c6c279 AD |
110 | var id = this.tree.model.store.getValue(item, 'id'); |
111 | var source_id = source.tree.model.store.getValue(source_item, 'id'); | |
112 | ||
113 | //console.log(id + " " + position + " " + source_id); | |
114 | ||
115 | if (source_id.match("FEED:")) { | |
116 | return ((id.match("CAT:") && position == "over") || | |
117 | (id.match("FEED:") && position != "over")); | |
118 | } else if (source_id.match("CAT:")) { | |
2a060a94 | 119 | return ((id.match("CAT:") && !id.match("CAT:0")) || |
49c6c279 AD |
120 | (id.match("root") && position == "over")); |
121 | } | |
2148e0d5 AD |
122 | }, |
123 | }); | |
124 |