]>
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
);
26 var icon
= dojo
.doc
.createElement('img');
27 if (args
.item
.icon
&& args
.item
.icon
[0]) {
28 icon
.src
= args
.item
.icon
[0];
30 icon
.src
= 'images/blank_icon.gif';
32 icon
.className
= 'tinyFeedIcon';
33 domConstruct
.place(icon
, tnode
.iconNode
, 'only');
35 var param
= this.model
.store
.getValue(args
.item
, 'param');
38 param
= dojo
.doc
.createElement('span');
39 param
.className
= 'feedParam';
40 param
.innerHTML
= args
.item
.param
[0];
41 //domConstruct.place(param, tnode.labelNode, 'after');
42 domConstruct
.place(param
, tnode
.rowNode
, 'first');
45 var id
= args
.item
.id
[0];
46 var bare_id
= parseInt(id
.substr(id
.indexOf(':')+1));
48 if (id
.match("CAT:") && bare_id
> 0) {
49 var menu
= new dijit
.Menu();
50 menu
.row_id
= bare_id
;
51 menu
.item
= args
.item
;
53 menu
.addChild(new dijit
.MenuItem({
54 label
: __("Edit category"),
56 editCat(this.getParent().row_id
, this.getParent().item
, null);
60 menu
.addChild(new dijit
.MenuItem({
61 label
: __("Remove category"),
63 removeCategory(this.getParent().row_id
, this.getParent().item
);
66 menu
.bindDomNode(tnode
.domNode
);
68 } else if (id
.match("FEED:")) {
69 var menu
= new dijit
.Menu();
70 menu
.row_id
= bare_id
;
71 menu
.item
= args
.item
;
73 menu
.addChild(new dijit
.MenuItem({
74 label
: __("Edit feed"),
76 editFeed(this.getParent().row_id
);
79 menu
.addChild(new dijit
.MenuItem({
80 label
: __("Unsubscribe"),
82 unsubscribeFeed(this.getParent().row_id
, this.getParent().item
.name
);
85 menu
.bindDomNode(tnode
.domNode
);
92 onDndDrop: function() {
93 this.inherited(arguments
);
94 this.tree
.model
.store
.save();
96 getRowClass: function (item
, opened
) {
97 return (!item
.error
|| item
.error
== '') ? "dijitTreeRow" :
100 getIconClass: function (item
, opened
) {
101 return (!item
|| this.model
.store
.getValue(item
, 'type') == 'category') ? (opened
? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
103 checkItemAcceptance: function(target
, source
, position
) {
104 var item
= dijit
.getEnclosingWidget(target
).item
;
106 // disable copying items
107 source
.copyState = function() { return false; };
109 var source_item
= false;
111 source
.forInSelectedItems(function(node
) {
112 source_item
= node
.data
.item
;
115 if (!source_item
|| !item
) return false;
117 var id
= this.tree
.model
.store
.getValue(item
, 'id');
118 var source_id
= source
.tree
.model
.store
.getValue(source_item
, 'id');
120 //console.log(id + " " + position + " " + source_id);
122 if (source_id
.match("FEED:")) {
123 return ((id
.match("CAT:") && position
== "over") ||
124 (id
.match("FEED:") && position
!= "over"));
125 } else if (source_id
.match("CAT:")) {
126 return ((id
.match("CAT:") && !id
.match("CAT:0")) ||
127 (id
.match("root") && position
== "over"));