]> git.wh0rd.org - tt-rss.git/blob - js/PrefFeedTree.js
remove old category editor
[tt-rss.git] / js / PrefFeedTree.js
1 dojo.provide("fox.PrefFeedTree");
2 dojo.provide("fox.PrefFeedStore");
3
4 dojo.require("lib.CheckBoxTree");
5 dojo.require("dojo.data.ItemFileWriteStore");
6
7 dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
8
9 _saveEverything: function(saveCompleteCallback, saveFailedCallback,
10 newFileContentString) {
11
12 dojo.xhrPost({
13 url: "backend.php",
14 content: {op: "pref-feeds", method: "savefeedorder",
15 payload: newFileContentString},
16 error: saveFailedCallback,
17 load: saveCompleteCallback});
18 },
19
20 });
21
22 dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, {
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
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
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
83 return tnode;
84 },
85 onDndDrop: function() {
86 this.inherited(arguments);
87 this.tree.model.store.save();
88 },
89 getRowClass: function (item, opened) {
90 return (!item.error || item.error == '') ? "dijitTreeRow" :
91 "dijitTreeRow Error";
92 },
93 getIconClass: function (item, opened) {
94 return (!item || this.model.store.getValue(item, 'type') == 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
95 },
96 checkItemAcceptance: function(target, source, position) {
97 var item = dijit.getEnclosingWidget(target).item;
98
99 // disable copying items
100 source.copyState = function() { return false; };
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
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:")) {
119 return ((id.match("CAT:") && !id.match("CAT:0")) ||
120 (id.match("root") && position == "over"));
121 }
122 },
123 });
124