]>
git.wh0rd.org - tt-rss.git/blob - js/PrefFeedTree.js
1 define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare
, domConstruct
) {
3 return declare("fox.PrefFeedTree", lib
.CheckBoxTree
, {
4 _createTreeNode: function(args
) {
5 var tnode
= this.inherited(arguments
);
7 var icon
= dojo
.doc
.createElement('img');
8 if (args
.item
.icon
&& args
.item
.icon
[0]) {
9 icon
.src
= args
.item
.icon
[0];
11 icon
.src
= 'images/blank_icon.gif';
13 icon
.className
= 'tinyFeedIcon';
14 domConstruct
.place(icon
, tnode
.iconNode
, 'only');
16 var param
= this.model
.store
.getValue(args
.item
, 'param');
19 param
= dojo
.doc
.createElement('span');
20 param
.className
= 'feedParam';
21 param
.innerHTML
= args
.item
.param
[0];
22 //domConstruct.place(param, tnode.labelNode, 'after');
23 domConstruct
.place(param
, tnode
.rowNode
, 'first');
26 var id
= args
.item
.id
[0];
27 var bare_id
= parseInt(id
.substr(id
.indexOf(':')+1));
29 if (id
.match("CAT:") && bare_id
> 0) {
30 var menu
= new dijit
.Menu();
31 menu
.row_id
= bare_id
;
32 menu
.item
= args
.item
;
34 menu
.addChild(new dijit
.MenuItem({
35 label
: __("Edit category"),
37 editCat(this.getParent().row_id
, this.getParent().item
, null);
41 menu
.addChild(new dijit
.MenuItem({
42 label
: __("Remove category"),
44 removeCategory(this.getParent().row_id
, this.getParent().item
);
47 menu
.bindDomNode(tnode
.domNode
);
49 } else if (id
.match("FEED:")) {
50 var menu
= new dijit
.Menu();
51 menu
.row_id
= bare_id
;
52 menu
.item
= args
.item
;
54 menu
.addChild(new dijit
.MenuItem({
55 label
: __("Edit feed"),
57 editFeed(this.getParent().row_id
);
60 menu
.addChild(new dijit
.MenuItem({
61 label
: __("Unsubscribe"),
63 unsubscribeFeed(this.getParent().row_id
, this.getParent().item
.name
);
66 menu
.bindDomNode(tnode
.domNode
);
73 onDndDrop: function() {
74 this.inherited(arguments
);
75 this.tree
.model
.store
.save();
77 getRowClass: function (item
, opened
) {
78 return (!item
.error
|| item
.error
== '') ? "dijitTreeRow" :
81 getIconClass: function (item
, opened
) {
82 return (!item
|| this.model
.store
.getValue(item
, 'type') == 'category') ? (opened
? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
84 checkItemAcceptance: function(target
, source
, position
) {
85 var item
= dijit
.getEnclosingWidget(target
).item
;
87 // disable copying items
88 source
.copyState = function() { return false; };
90 var source_item
= false;
92 source
.forInSelectedItems(function(node
) {
93 source_item
= node
.data
.item
;
96 if (!source_item
|| !item
) return false;
98 var id
= this.tree
.model
.store
.getValue(item
, 'id');
99 var source_id
= source
.tree
.model
.store
.getValue(source_item
, 'id');
101 //console.log(id + " " + position + " " + source_id);
103 if (source_id
.match("FEED:")) {
104 return ((id
.match("CAT:") && position
== "over") ||
105 (id
.match("FEED:") && position
!= "over"));
106 } else if (source_id
.match("CAT:")) {
107 return ((id
.match("CAT:") && !id
.match("CAT:0")) ||
108 (id
.match("root") && position
== "over"));