2016-08-10 10:40:24 +00:00
|
|
|
require(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {
|
2010-11-17 20:32:32 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
return declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
|
2010-11-17 20:32:32 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
|
|
|
|
newFileContentString) {
|
2012-08-13 10:47:43 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
dojo.xhrPost({
|
|
|
|
url: "backend.php",
|
|
|
|
content: {op: "pref-feeds", method: "savefeedorder",
|
|
|
|
payload: newFileContentString},
|
|
|
|
error: saveFailedCallback,
|
|
|
|
load: saveCompleteCallback});
|
|
|
|
},
|
2010-11-18 10:46:11 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
});
|
2010-11-18 10:46:11 +00:00
|
|
|
|
2012-08-13 10:47:43 +00:00
|
|
|
});
|
2010-11-18 10:46:11 +00:00
|
|
|
|
2017-01-21 17:54:36 +00:00
|
|
|
require(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) {
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
return declare("fox.PrefFeedTree", lib.CheckBoxTree, {
|
|
|
|
_createTreeNode: function(args) {
|
|
|
|
var tnode = this.inherited(arguments);
|
|
|
|
|
2017-01-20 17:29:59 +00:00
|
|
|
if (args.item.icon) {
|
|
|
|
var icon = dojo.doc.createElement('img');
|
|
|
|
icon.src = args.item.icon[0];
|
|
|
|
icon.className = 'tinyFeedIcon';
|
|
|
|
domConstruct.place(icon, tnode.iconNode, 'only');
|
|
|
|
}
|
2016-08-10 10:40:24 +00: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];
|
2017-01-21 17:54:36 +00:00
|
|
|
//domConstruct.place(param, tnode.labelNode, 'after');
|
|
|
|
domConstruct.place(param, tnode.rowNode, 'first');
|
2016-08-10 10:40:24 +00: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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return tnode;
|
|
|
|
},
|
|
|
|
onDndDrop: function() {
|
|
|
|
this.inherited(arguments);
|
|
|
|
this.tree.model.store.save();
|
|
|
|
},
|
|
|
|
getRowClass: function (item, opened) {
|
|
|
|
return (!item.error || item.error == '') ? "dijitTreeRow" :
|
|
|
|
"dijitTreeRow Error";
|
|
|
|
},
|
|
|
|
getIconClass: function (item, opened) {
|
|
|
|
return (!item || this.model.store.getValue(item, 'type') == 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
|
|
|
|
},
|
|
|
|
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 = 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") ||
|
2010-11-18 07:15:14 +00:00
|
|
|
(id.match("FEED:") && position != "over"));
|
2016-08-10 10:40:24 +00:00
|
|
|
} else if (source_id.match("CAT:")) {
|
|
|
|
return ((id.match("CAT:") && !id.match("CAT:0")) ||
|
2010-11-18 07:15:14 +00:00
|
|
|
(id.match("root") && position == "over"));
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
2010-11-17 20:32:32 +00:00
|
|
|
});
|
|
|
|
|