]>
git.wh0rd.org - tt-rss.git/blob - js/PrefFeedTree.js
2 define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare
, domConstruct
) {
4 return declare("fox.PrefFeedTree", lib
.CheckBoxTree
, {
5 _createTreeNode: function(args
) {
6 const tnode
= this.inherited(arguments
);
8 const icon
= dojo
.doc
.createElement('img');
9 if (args
.item
.icon
&& args
.item
.icon
[0]) {
10 icon
.src
= args
.item
.icon
[0];
12 icon
.src
= 'images/blank_icon.gif';
14 icon
.className
= 'tinyFeedIcon';
15 domConstruct
.place(icon
, tnode
.iconNode
, 'only');
17 let param
= this.model
.store
.getValue(args
.item
, 'param');
20 param
= dojo
.doc
.createElement('span');
21 param
.className
= 'feedParam';
22 param
.innerHTML
= args
.item
.param
[0];
23 //domConstruct.place(param, tnode.labelNode, 'after');
24 domConstruct
.place(param
, tnode
.rowNode
, 'first');
27 const id
= args
.item
.id
[0];
28 const bare_id
= parseInt(id
.substr(id
.indexOf(':')+1));
30 if (id
.match("CAT:") && bare_id
> 0) {
31 var menu
= new dijit
.Menu();
32 menu
.row_id
= bare_id
;
33 menu
.item
= args
.item
;
35 menu
.addChild(new dijit
.MenuItem({
36 label
: __("Edit category"),
38 editCat(this.getParent().row_id
, this.getParent().item
, null);
42 menu
.addChild(new dijit
.MenuItem({
43 label
: __("Remove category"),
45 removeCategory(this.getParent().row_id
, this.getParent().item
);
48 menu
.bindDomNode(tnode
.domNode
);
50 } else if (id
.match("FEED:")) {
51 var menu
= new dijit
.Menu();
52 menu
.row_id
= bare_id
;
53 menu
.item
= args
.item
;
55 menu
.addChild(new dijit
.MenuItem({
56 label
: __("Edit feed"),
58 editFeed(this.getParent().row_id
);
61 menu
.addChild(new dijit
.MenuItem({
62 label
: __("Unsubscribe"),
64 unsubscribeFeed(this.getParent().row_id
, this.getParent().item
.name
);
67 menu
.bindDomNode(tnode
.domNode
);
74 onDndDrop: function() {
75 this.inherited(arguments
);
76 this.tree
.model
.store
.save();
78 getRowClass: function (item
, opened
) {
79 return (!item
.error
|| item
.error
== '') ? "dijitTreeRow" :
82 getIconClass: function (item
, opened
) {
83 return (!item
|| this.model
.store
.getValue(item
, 'type') == 'category') ? (opened
? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
85 checkItemAcceptance: function(target
, source
, position
) {
86 const item
= dijit
.getEnclosingWidget(target
).item
;
88 // disable copying items
89 source
.copyState = function() { return false; };
91 let source_item
= false;
93 source
.forInSelectedItems(function(node
) {
94 source_item
= node
.data
.item
;
97 if (!source_item
|| !item
) return false;
99 const id
= this.tree
.model
.store
.getValue(item
, 'id');
100 const source_id
= source
.tree
.model
.store
.getValue(source_item
, 'id');
102 //console.log(id + " " + position + " " + source_id);
104 if (source_id
.match("FEED:")) {
105 return ((id
.match("CAT:") && position
== "over") ||
106 (id
.match("FEED:") && position
!= "over"));
107 } else if (source_id
.match("CAT:")) {
108 return ((id
.match("CAT:") && !id
.match("CAT:0")) ||
109 (id
.match("root") && position
== "over"));