summaryrefslogtreecommitdiff
path: root/PrefFeedTree.js
blob: 511f4fafeb7437fdb092268145823b1d9fb2253b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
dojo.provide("fox.PrefFeedTree");
dojo.provide("fox.PrefFeedStore");

dojo.require("lib.CheckBoxTree");

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});
	},

});		

dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, {
	onDndDrop: function() {
		this.inherited(arguments);
		this.tree.model.store.save();
	},
	checkItemAcceptance: function(target, source, position) {
		var item = dijit.getEnclosingWidget(target).item;

		// 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;

		var id = String(item.id);
		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"));
		}
	},
});