]>
git.wh0rd.org - tt-rss.git/blob - js/PrefFeedTree.js
1 require(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare
) {
3 return declare("fox.PrefFeedStore", dojo
.data
.ItemFileWriteStore
, {
5 _saveEverything: function(saveCompleteCallback
, saveFailedCallback
,
6 newFileContentString
) {
10 content
: {op
: "pref-feeds", method
: "savefeedorder",
11 payload
: newFileContentString
},
12 error
: saveFailedCallback
,
13 load
: saveCompleteCallback
});
20 require(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare
, domConstruct
) {
22 return declare("fox.PrefFeedTree", lib
.CheckBoxTree
, {
23 _createTreeNode: function(args
) {
24 var tnode
= this.inherited(arguments
);
27 var icon
= dojo
.doc
.createElement('img');
28 icon
.src
= args
.item
.icon
[0];
29 icon
.className
= 'tinyFeedIcon';
30 domConstruct
.place(icon
, tnode
.iconNode
, 'only');
33 var param
= this.model
.store
.getValue(args
.item
, 'param');
36 param
= dojo
.doc
.createElement('span');
37 param
.className
= 'feedParam';
38 param
.innerHTML
= args
.item
.param
[0];
39 //domConstruct.place(param, tnode.labelNode, 'after');
40 domConstruct
.place(param
, tnode
.rowNode
, 'first');
43 var id
= args
.item
.id
[0];
44 var bare_id
= parseInt(id
.substr(id
.indexOf(':')+1));
46 if (id
.match("CAT:") && bare_id
> 0) {
47 var menu
= new dijit
.Menu();
48 menu
.row_id
= bare_id
;
49 menu
.item
= args
.item
;
51 menu
.addChild(new dijit
.MenuItem({
52 label
: __("Edit category"),
54 editCat(this.getParent().row_id
, this.getParent().item
, null);
58 menu
.addChild(new dijit
.MenuItem({
59 label
: __("Remove category"),
61 removeCategory(this.getParent().row_id
, this.getParent().item
);
64 menu
.bindDomNode(tnode
.domNode
);
66 } else if (id
.match("FEED:")) {
67 var menu
= new dijit
.Menu();
68 menu
.row_id
= bare_id
;
69 menu
.item
= args
.item
;
71 menu
.addChild(new dijit
.MenuItem({
72 label
: __("Edit feed"),
74 editFeed(this.getParent().row_id
);
77 menu
.addChild(new dijit
.MenuItem({
78 label
: __("Unsubscribe"),
80 unsubscribeFeed(this.getParent().row_id
, this.getParent().item
.name
);
83 menu
.bindDomNode(tnode
.domNode
);
90 onDndDrop: function() {
91 this.inherited(arguments
);
92 this.tree
.model
.store
.save();
94 getRowClass: function (item
, opened
) {
95 return (!item
.error
|| item
.error
== '') ? "dijitTreeRow" :
98 getIconClass: function (item
, opened
) {
99 return (!item
|| this.model
.store
.getValue(item
, 'type') == 'category') ? (opened
? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
101 checkItemAcceptance: function(target
, source
, position
) {
102 var item
= dijit
.getEnclosingWidget(target
).item
;
104 // disable copying items
105 source
.copyState = function() { return false; };
107 var source_item
= false;
109 source
.forInSelectedItems(function(node
) {
110 source_item
= node
.data
.item
;
113 if (!source_item
|| !item
) return false;
115 var id
= this.tree
.model
.store
.getValue(item
, 'id');
116 var source_id
= source
.tree
.model
.store
.getValue(source_item
, 'id');
118 //console.log(id + " " + position + " " + source_id);
120 if (source_id
.match("FEED:")) {
121 return ((id
.match("CAT:") && position
== "over") ||
122 (id
.match("FEED:") && position
!= "over"));
123 } else if (source_id
.match("CAT:")) {
124 return ((id
.match("CAT:") && !id
.match("CAT:0")) ||
125 (id
.match("root") && position
== "over"));