2010-11-18 13:49:26 +01:00
|
|
|
dojo.provide("fox.PrefFilterTree");
|
|
|
|
|
|
|
|
dojo.require("lib.CheckBoxTree");
|
2013-03-31 15:15:23 +02:00
|
|
|
dojo.require("dojo.data.ItemFileWriteStore");
|
|
|
|
|
|
|
|
dojo.declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, {
|
|
|
|
|
|
|
|
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
|
|
|
|
newFileContentString) {
|
|
|
|
|
|
|
|
dojo.xhrPost({
|
|
|
|
url: "backend.php",
|
|
|
|
content: {op: "pref-filters", method: "savefilterorder",
|
|
|
|
payload: newFileContentString},
|
|
|
|
error: saveFailedCallback,
|
|
|
|
load: saveCompleteCallback});
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
2010-11-18 13:49:26 +01:00
|
|
|
|
|
|
|
dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, {
|
|
|
|
_createTreeNode: function(args) {
|
|
|
|
var tnode = this.inherited(arguments);
|
|
|
|
|
|
|
|
var enabled = this.model.store.getValue(args.item, 'enabled');
|
|
|
|
var param = this.model.store.getValue(args.item, 'param');
|
2014-04-02 10:15:33 +02:00
|
|
|
var rules = this.model.store.getValue(args.item, 'rules');
|
2010-11-18 13:49:26 +01:00
|
|
|
|
|
|
|
if (param) {
|
|
|
|
param = dojo.doc.createElement('span');
|
2015-08-17 11:33:07 +02:00
|
|
|
param.className = (enabled != false) ? 'labelParam' : 'labelParam filterDisabled';
|
2010-11-18 13:49:26 +01:00
|
|
|
param.innerHTML = args.item.param[0];
|
2013-06-07 08:01:11 +02:00
|
|
|
dojo.place(param, tnode.rowNode, 'first');
|
2010-11-18 13:49:26 +01:00
|
|
|
}
|
|
|
|
|
2014-04-02 10:15:33 +02:00
|
|
|
if (rules) {
|
|
|
|
param = dojo.doc.createElement('span');
|
|
|
|
param.className = 'filterRules';
|
|
|
|
param.innerHTML = rules;
|
|
|
|
dojo.place(param, tnode.rowNode, 'next');
|
|
|
|
}
|
|
|
|
|
2013-07-10 11:09:12 +02:00
|
|
|
if (this.model.store.getValue(args.item, 'id') != 'root') {
|
|
|
|
var img = dojo.doc.createElement('img');
|
|
|
|
img.src ='images/filter.png';
|
|
|
|
img.className = 'markedPic';
|
|
|
|
tnode._filterIconNode = img;
|
|
|
|
dojo.place(tnode._filterIconNode, tnode.labelNode, 'before');
|
|
|
|
}
|
|
|
|
|
2010-11-18 13:49:26 +01:00
|
|
|
return tnode;
|
|
|
|
},
|
|
|
|
|
|
|
|
getLabel: function(item) {
|
|
|
|
var label = item.name;
|
|
|
|
|
|
|
|
var feed = this.model.store.getValue(item, 'feed');
|
|
|
|
var inverse = this.model.store.getValue(item, 'inverse');
|
|
|
|
|
|
|
|
if (feed)
|
2011-12-27 09:52:33 +01:00
|
|
|
label += " (" + __("in") + " " + feed + ")";
|
2010-11-18 13:49:26 +01:00
|
|
|
|
|
|
|
if (inverse)
|
|
|
|
label += " (" + __("Inverse") + ")";
|
|
|
|
|
|
|
|
/* if (item.param)
|
2011-12-27 09:52:33 +01:00
|
|
|
label = "<span class=\"labelFixedLength\">" + label +
|
2010-11-18 13:49:26 +01:00
|
|
|
"</span>" + item.param[0]; */
|
|
|
|
|
|
|
|
return label;
|
|
|
|
},
|
2010-11-19 16:38:25 +01:00
|
|
|
getIconClass: function (item, opened) {
|
|
|
|
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible";
|
|
|
|
},
|
2010-11-18 13:49:26 +01:00
|
|
|
getLabelClass: function (item, opened) {
|
|
|
|
var enabled = this.model.store.getValue(item, 'enabled');
|
2015-08-17 11:33:07 +02:00
|
|
|
return (enabled != false) ? "dijitTreeLabel labelFixedLength" : "dijitTreeLabel labelFixedLength filterDisabled";
|
2010-11-18 13:49:26 +01:00
|
|
|
},
|
|
|
|
getRowClass: function (item, opened) {
|
2011-12-27 09:52:33 +01:00
|
|
|
return (!item.error || item.error == '') ? "dijitTreeRow" :
|
2010-11-18 13:49:26 +01:00
|
|
|
"dijitTreeRow Error";
|
|
|
|
},
|
2013-03-31 15:15:23 +02:00
|
|
|
checkItemAcceptance: function(target, source, position) {
|
|
|
|
var item = dijit.getEnclosingWidget(target).item;
|
|
|
|
|
|
|
|
// disable copying items
|
|
|
|
source.copyState = function() { return false; };
|
|
|
|
|
|
|
|
return position != 'over';
|
|
|
|
},
|
|
|
|
onDndDrop: function() {
|
|
|
|
this.inherited(arguments);
|
|
|
|
this.tree.model.store.save();
|
|
|
|
},
|
2010-11-18 13:49:26 +01:00
|
|
|
});
|
|
|
|
|