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