2010-11-17 21:32:32 +01:00
|
|
|
dojo.provide("fox.PrefFeedTree");
|
2010-11-18 11:46:11 +01:00
|
|
|
dojo.provide("fox.PrefFeedStore");
|
2010-11-17 21:32:32 +01:00
|
|
|
|
|
|
|
dojo.require("lib.CheckBoxTree");
|
2010-11-19 16:49:06 +01:00
|
|
|
dojo.require("dojo.data.ItemFileWriteStore");
|
2010-11-17 21:32:32 +01:00
|
|
|
|
2010-11-18 11:46:11 +01:00
|
|
|
dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
|
2012-08-13 12:47:43 +02:00
|
|
|
|
2010-11-18 11:46:11 +01:00
|
|
|
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
|
|
|
|
newFileContentString) {
|
|
|
|
|
|
|
|
dojo.xhrPost({
|
|
|
|
url: "backend.php",
|
2011-12-12 19:46:25 +01:00
|
|
|
content: {op: "pref-feeds", method: "savefeedorder",
|
2010-11-18 11:46:11 +01:00
|
|
|
payload: newFileContentString},
|
|
|
|
error: saveFailedCallback,
|
|
|
|
load: saveCompleteCallback});
|
|
|
|
},
|
|
|
|
|
2012-08-13 12:47:43 +02:00
|
|
|
});
|
2010-11-18 11:46:11 +01:00
|
|
|
|
2010-11-17 21:32:32 +01:00
|
|
|
dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, {
|
2010-11-18 12:20:43 +01:00
|
|
|
_createTreeNode: function(args) {
|
|
|
|
var tnode = this.inherited(arguments);
|
|
|
|
|
|
|
|
if (args.item.icon)
|
|
|
|
tnode.iconNode.src = args.item.icon[0];
|
|
|
|
|
2010-12-28 09:39:12 +01:00
|
|
|
var param = this.model.store.getValue(args.item, 'param');
|
|
|
|
|
|
|
|
if (param) {
|
|
|
|
param = dojo.doc.createElement('span');
|
|
|
|
param.className = 'feedParam';
|
|
|
|
param.innerHTML = args.item.param[0];
|
2013-06-07 08:01:11 +02:00
|
|
|
//dojo.place(param, tnode.labelNode, 'after');
|
|
|
|
dojo.place(param, tnode.rowNode, 'first');
|
2010-12-28 09:39:12 +01:00
|
|
|
}
|
|
|
|
|
2012-08-15 07:38:57 +02:00
|
|
|
var id = args.item.id[0];
|
|
|
|
var bare_id = parseInt(id.substr(id.indexOf(':')+1));
|
|
|
|
|
|
|
|
if (id.match("CAT:") && bare_id > 0) {
|
|
|
|
var menu = new dijit.Menu();
|
|
|
|
menu.row_id = bare_id;
|
|
|
|
menu.item = args.item;
|
|
|
|
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Edit category"),
|
|
|
|
onClick: function() {
|
|
|
|
editCat(this.getParent().row_id, this.getParent().item, null);
|
|
|
|
}}));
|
|
|
|
|
|
|
|
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Remove category"),
|
|
|
|
onClick: function() {
|
|
|
|
removeCategory(this.getParent().row_id, this.getParent().item);
|
|
|
|
}}));
|
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
|
|
|
} else if (id.match("FEED:")) {
|
|
|
|
var menu = new dijit.Menu();
|
|
|
|
menu.row_id = bare_id;
|
|
|
|
menu.item = args.item;
|
|
|
|
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Edit feed"),
|
|
|
|
onClick: function() {
|
|
|
|
editFeed(this.getParent().row_id);
|
|
|
|
}}));
|
|
|
|
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Unsubscribe"),
|
|
|
|
onClick: function() {
|
|
|
|
unsubscribeFeed(this.getParent().row_id, this.getParent().item.name);
|
|
|
|
}}));
|
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-11-18 12:20:43 +01:00
|
|
|
return tnode;
|
|
|
|
},
|
2010-11-18 11:46:11 +01:00
|
|
|
onDndDrop: function() {
|
|
|
|
this.inherited(arguments);
|
|
|
|
this.tree.model.store.save();
|
|
|
|
},
|
2010-11-18 12:20:43 +01:00
|
|
|
getRowClass: function (item, opened) {
|
2012-08-13 12:47:43 +02:00
|
|
|
return (!item.error || item.error == '') ? "dijitTreeRow" :
|
2010-11-18 12:20:43 +01:00
|
|
|
"dijitTreeRow Error";
|
|
|
|
},
|
|
|
|
getIconClass: function (item, opened) {
|
2010-11-18 16:25:27 +01:00
|
|
|
return (!item || this.model.store.getValue(item, 'type') == 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
|
2010-11-18 12:20:43 +01:00
|
|
|
},
|
2010-11-17 21:32:32 +01:00
|
|
|
checkItemAcceptance: function(target, source, position) {
|
|
|
|
var item = dijit.getEnclosingWidget(target).item;
|
|
|
|
|
2010-11-18 08:15:14 +01:00
|
|
|
// disable copying items
|
2011-12-10 18:26:59 +01:00
|
|
|
source.copyState = function() { return false; };
|
2010-11-18 08:15:14 +01:00
|
|
|
|
|
|
|
var source_item = false;
|
|
|
|
|
|
|
|
source.forInSelectedItems(function(node) {
|
|
|
|
source_item = node.data.item;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!source_item || !item) return false;
|
|
|
|
|
|
|
|
var id = this.tree.model.store.getValue(item, 'id');
|
|
|
|
var source_id = source.tree.model.store.getValue(source_item, 'id');
|
|
|
|
|
|
|
|
//console.log(id + " " + position + " " + source_id);
|
|
|
|
|
|
|
|
if (source_id.match("FEED:")) {
|
|
|
|
return ((id.match("CAT:") && position == "over") ||
|
|
|
|
(id.match("FEED:") && position != "over"));
|
|
|
|
} else if (source_id.match("CAT:")) {
|
2012-08-13 12:47:43 +02:00
|
|
|
return ((id.match("CAT:") && !id.match("CAT:0")) ||
|
2010-11-18 08:15:14 +01:00
|
|
|
(id.match("root") && position == "over"));
|
|
|
|
}
|
2010-11-17 21:32:32 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|