]>
git.wh0rd.org - tt-rss.git/blob - js/PrefFeedTree.js
1 dojo
.provide("fox.PrefFeedTree");
2 dojo
.provide("fox.PrefFeedStore");
4 dojo
.require("lib.CheckBoxTree");
5 dojo
.require("dojo.data.ItemFileWriteStore");
7 dojo
.declare("fox.PrefFeedStore", dojo
.data
.ItemFileWriteStore
, {
9 _saveEverything: function(saveCompleteCallback
, saveFailedCallback
,
10 newFileContentString
) {
14 content
: {op
: "pref-feeds", method
: "savefeedorder",
15 payload
: newFileContentString
},
16 error
: saveFailedCallback
,
17 load
: saveCompleteCallback
});
22 dojo
.declare("fox.PrefFeedTree", lib
.CheckBoxTree
, {
23 _createTreeNode: function(args
) {
24 var tnode
= this.inherited(arguments
);
27 tnode
.iconNode
.src
= args
.item
.icon
[0];
29 var param
= this.model
.store
.getValue(args
.item
, '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');
39 var id
= args
.item
.id
[0];
40 var bare_id
= parseInt(id
.substr(id
.indexOf(':')+1));
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
;
47 menu
.addChild(new dijit
.MenuItem({
48 label
: __("Edit category"),
50 editCat(this.getParent().row_id
, this.getParent().item
, null);
54 menu
.addChild(new dijit
.MenuItem({
55 label
: __("Remove category"),
57 removeCategory(this.getParent().row_id
, this.getParent().item
);
60 menu
.bindDomNode(tnode
.domNode
);
62 } else if (id
.match("FEED:")) {
63 var menu
= new dijit
.Menu();
64 menu
.row_id
= bare_id
;
65 menu
.item
= args
.item
;
67 menu
.addChild(new dijit
.MenuItem({
68 label
: __("Edit feed"),
70 editFeed(this.getParent().row_id
);
73 menu
.addChild(new dijit
.MenuItem({
74 label
: __("Unsubscribe"),
76 unsubscribeFeed(this.getParent().row_id
, this.getParent().item
.name
);
79 menu
.bindDomNode(tnode
.domNode
);
86 onDndDrop: function() {
87 this.inherited(arguments
);
88 this.tree
.model
.store
.save();
90 getRowClass: function (item
, opened
) {
91 return (!item
.error
|| item
.error
== '') ? "dijitTreeRow" :
94 getIconClass: function (item
, opened
) {
95 return (!item
|| this.model
.store
.getValue(item
, 'type') == 'category') ? (opened
? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
97 checkItemAcceptance: function(target
, source
, position
) {
98 var item
= dijit
.getEnclosingWidget(target
).item
;
100 // disable copying items
101 source
.copyState = function() { return false; };
103 var source_item
= false;
105 source
.forInSelectedItems(function(node
) {
106 source_item
= node
.data
.item
;
109 if (!source_item
|| !item
) return false;
111 var id
= this.tree
.model
.store
.getValue(item
, 'id');
112 var source_id
= source
.tree
.model
.store
.getValue(source_item
, 'id');
114 //console.log(id + " " + position + " " + source_id);
116 if (source_id
.match("FEED:")) {
117 return ((id
.match("CAT:") && position
== "over") ||
118 (id
.match("FEED:") && position
!= "over"));
119 } else if (source_id
.match("CAT:")) {
120 return ((id
.match("CAT:") && !id
.match("CAT:0")) ||
121 (id
.match("root") && position
== "over"));