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