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, {
|
|
|
|
|
|
|
|
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
|
|
|
|
newFileContentString) {
|
|
|
|
|
|
|
|
dojo.xhrPost({
|
|
|
|
url: "backend.php",
|
|
|
|
content: {op: "pref-feeds", subop: "savefeedorder",
|
|
|
|
payload: newFileContentString},
|
|
|
|
error: saveFailedCallback,
|
|
|
|
load: saveCompleteCallback});
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
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];
|
|
|
|
|
|
|
|
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) {
|
|
|
|
return (!item.error || item.error == '') ? "dijitTreeRow" :
|
|
|
|
"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
|
|
|
|
source.copyState = function() { return false; }
|
|
|
|
|
|
|
|
var source_item = false;
|
|
|
|
|
|
|
|
source.forInSelectedItems(function(node) {
|
|
|
|
source_item = node.data.item;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!source_item || !item) return false;
|
|
|
|
|
2010-11-17 21:32:32 +01:00
|
|
|
var id = String(item.id);
|
2010-11-18 08:15:14 +01:00
|
|
|
var source_id = String(source_item.id);
|
|
|
|
|
|
|
|
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:")) {
|
|
|
|
return ((id.match("CAT:") && position != "over") ||
|
|
|
|
(id.match("root") && position == "over"));
|
|
|
|
}
|
2010-11-17 21:32:32 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|