]>
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');
38 var id
= args
.item
.id
[0];
39 var bare_id
= parseInt(id
.substr(id
.indexOf(':')+1));
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
;
46 menu
.addChild(new dijit
.MenuItem({
47 label
: __("Edit category"),
49 editCat(this.getParent().row_id
, this.getParent().item
, null);
53 menu
.addChild(new dijit
.MenuItem({
54 label
: __("Remove category"),
56 removeCategory(this.getParent().row_id
, this.getParent().item
);
59 menu
.bindDomNode(tnode
.domNode
);
61 } else if (id
.match("FEED:")) {
62 var menu
= new dijit
.Menu();
63 menu
.row_id
= bare_id
;
64 menu
.item
= args
.item
;
66 menu
.addChild(new dijit
.MenuItem({
67 label
: __("Edit feed"),
69 editFeed(this.getParent().row_id
);
72 menu
.addChild(new dijit
.MenuItem({
73 label
: __("Unsubscribe"),
75 unsubscribeFeed(this.getParent().row_id
, this.getParent().item
.name
);
78 menu
.bindDomNode(tnode
.domNode
);
85 onDndDrop: function() {
86 this.inherited(arguments
);
87 this.tree
.model
.store
.save();
89 getRowClass: function (item
, opened
) {
90 return (!item
.error
|| item
.error
== '') ? "dijitTreeRow" :
93 getIconClass: function (item
, opened
) {
94 return (!item
|| this.model
.store
.getValue(item
, 'type') == 'category') ? (opened
? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
96 checkItemAcceptance: function(target
, source
, position
) {
97 var item
= dijit
.getEnclosingWidget(target
).item
;
99 // disable copying items
100 source
.copyState = function() { return false; };
102 var source_item
= false;
104 source
.forInSelectedItems(function(node
) {
105 source_item
= node
.data
.item
;
108 if (!source_item
|| !item
) return false;
110 var id
= this.tree
.model
.store
.getValue(item
, 'id');
111 var source_id
= source
.tree
.model
.store
.getValue(source_item
, 'id');
113 //console.log(id + " " + position + " " + source_id);
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"));