Merge branch 'master' into german-translation
commit
2842cf6e45
File diff suppressed because it is too large
Load Diff
@ -1,125 +1,126 @@
|
|||||||
dojo.provide("fox.PrefFeedTree");
|
require(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {
|
||||||
dojo.provide("fox.PrefFeedStore");
|
|
||||||
|
|
||||||
dojo.require("lib.CheckBoxTree");
|
return declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
|
||||||
dojo.require("dojo.data.ItemFileWriteStore");
|
|
||||||
|
|
||||||
dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, {
|
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
|
||||||
|
newFileContentString) {
|
||||||
|
|
||||||
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
|
dojo.xhrPost({
|
||||||
newFileContentString) {
|
url: "backend.php",
|
||||||
|
content: {op: "pref-feeds", method: "savefeedorder",
|
||||||
|
payload: newFileContentString},
|
||||||
|
error: saveFailedCallback,
|
||||||
|
load: saveCompleteCallback});
|
||||||
|
},
|
||||||
|
|
||||||
dojo.xhrPost({
|
});
|
||||||
url: "backend.php",
|
|
||||||
content: {op: "pref-feeds", method: "savefeedorder",
|
|
||||||
payload: newFileContentString},
|
|
||||||
error: saveFailedCallback,
|
|
||||||
load: saveCompleteCallback});
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, {
|
require(["dojo/_base/declare", "lib/CheckBoxTree"], function (declare) {
|
||||||
_createTreeNode: function(args) {
|
|
||||||
var tnode = this.inherited(arguments);
|
return declare("fox.PrefFeedTree", lib.CheckBoxTree, {
|
||||||
|
_createTreeNode: function(args) {
|
||||||
if (args.item.icon)
|
var tnode = this.inherited(arguments);
|
||||||
tnode.iconNode.src = args.item.icon[0];
|
|
||||||
|
if (args.item.icon)
|
||||||
var param = this.model.store.getValue(args.item, 'param');
|
tnode.iconNode.src = args.item.icon[0];
|
||||||
|
|
||||||
if (param) {
|
var param = this.model.store.getValue(args.item, 'param');
|
||||||
param = dojo.doc.createElement('span');
|
|
||||||
param.className = 'feedParam';
|
if (param) {
|
||||||
param.innerHTML = args.item.param[0];
|
param = dojo.doc.createElement('span');
|
||||||
//dojo.place(param, tnode.labelNode, 'after');
|
param.className = 'feedParam';
|
||||||
dojo.place(param, tnode.rowNode, 'first');
|
param.innerHTML = args.item.param[0];
|
||||||
}
|
//dojo.place(param, tnode.labelNode, 'after');
|
||||||
|
dojo.place(param, tnode.rowNode, 'first');
|
||||||
var id = args.item.id[0];
|
}
|
||||||
var bare_id = parseInt(id.substr(id.indexOf(':')+1));
|
|
||||||
|
var id = args.item.id[0];
|
||||||
if (id.match("CAT:") && bare_id > 0) {
|
var bare_id = parseInt(id.substr(id.indexOf(':')+1));
|
||||||
var menu = new dijit.Menu();
|
|
||||||
menu.row_id = bare_id;
|
if (id.match("CAT:") && bare_id > 0) {
|
||||||
menu.item = args.item;
|
var menu = new dijit.Menu();
|
||||||
|
menu.row_id = bare_id;
|
||||||
menu.addChild(new dijit.MenuItem({
|
menu.item = args.item;
|
||||||
label: __("Edit category"),
|
|
||||||
onClick: function() {
|
menu.addChild(new dijit.MenuItem({
|
||||||
editCat(this.getParent().row_id, this.getParent().item, null);
|
label: __("Edit category"),
|
||||||
}}));
|
onClick: function() {
|
||||||
|
editCat(this.getParent().row_id, this.getParent().item, null);
|
||||||
|
}}));
|
||||||
menu.addChild(new dijit.MenuItem({
|
|
||||||
label: __("Remove category"),
|
|
||||||
onClick: function() {
|
menu.addChild(new dijit.MenuItem({
|
||||||
removeCategory(this.getParent().row_id, this.getParent().item);
|
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:")) {
|
menu.bindDomNode(tnode.domNode);
|
||||||
var menu = new dijit.Menu();
|
tnode._menu = menu;
|
||||||
menu.row_id = bare_id;
|
} else if (id.match("FEED:")) {
|
||||||
menu.item = args.item;
|
var menu = new dijit.Menu();
|
||||||
|
menu.row_id = bare_id;
|
||||||
menu.addChild(new dijit.MenuItem({
|
menu.item = args.item;
|
||||||
label: __("Edit feed"),
|
|
||||||
onClick: function() {
|
menu.addChild(new dijit.MenuItem({
|
||||||
editFeed(this.getParent().row_id);
|
label: __("Edit feed"),
|
||||||
}}));
|
onClick: function() {
|
||||||
|
editFeed(this.getParent().row_id);
|
||||||
menu.addChild(new dijit.MenuItem({
|
}}));
|
||||||
label: __("Unsubscribe"),
|
|
||||||
onClick: function() {
|
menu.addChild(new dijit.MenuItem({
|
||||||
unsubscribeFeed(this.getParent().row_id, this.getParent().item.name);
|
label: __("Unsubscribe"),
|
||||||
}}));
|
onClick: function() {
|
||||||
|
unsubscribeFeed(this.getParent().row_id, this.getParent().item.name);
|
||||||
menu.bindDomNode(tnode.domNode);
|
}}));
|
||||||
tnode._menu = menu;
|
|
||||||
|
menu.bindDomNode(tnode.domNode);
|
||||||
}
|
tnode._menu = menu;
|
||||||
|
|
||||||
return tnode;
|
}
|
||||||
},
|
|
||||||
onDndDrop: function() {
|
return tnode;
|
||||||
this.inherited(arguments);
|
},
|
||||||
this.tree.model.store.save();
|
onDndDrop: function() {
|
||||||
},
|
this.inherited(arguments);
|
||||||
getRowClass: function (item, opened) {
|
this.tree.model.store.save();
|
||||||
return (!item.error || item.error == '') ? "dijitTreeRow" :
|
},
|
||||||
"dijitTreeRow Error";
|
getRowClass: function (item, opened) {
|
||||||
},
|
return (!item.error || item.error == '') ? "dijitTreeRow" :
|
||||||
getIconClass: function (item, opened) {
|
"dijitTreeRow Error";
|
||||||
return (!item || this.model.store.getValue(item, 'type') == 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
|
},
|
||||||
},
|
getIconClass: function (item, opened) {
|
||||||
checkItemAcceptance: function(target, source, position) {
|
return (!item || this.model.store.getValue(item, 'type') == 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
|
||||||
var item = dijit.getEnclosingWidget(target).item;
|
},
|
||||||
|
checkItemAcceptance: function(target, source, position) {
|
||||||
// disable copying items
|
var item = dijit.getEnclosingWidget(target).item;
|
||||||
source.copyState = function() { return false; };
|
|
||||||
|
// disable copying items
|
||||||
var source_item = false;
|
source.copyState = function() { return false; };
|
||||||
|
|
||||||
source.forInSelectedItems(function(node) {
|
var source_item = false;
|
||||||
source_item = node.data.item;
|
|
||||||
});
|
source.forInSelectedItems(function(node) {
|
||||||
|
source_item = node.data.item;
|
||||||
if (!source_item || !item) return false;
|
});
|
||||||
|
|
||||||
var id = this.tree.model.store.getValue(item, 'id');
|
if (!source_item || !item) return false;
|
||||||
var source_id = source.tree.model.store.getValue(source_item, 'id');
|
|
||||||
|
var id = this.tree.model.store.getValue(item, 'id');
|
||||||
//console.log(id + " " + position + " " + source_id);
|
var source_id = source.tree.model.store.getValue(source_item, 'id');
|
||||||
|
|
||||||
if (source_id.match("FEED:")) {
|
//console.log(id + " " + position + " " + source_id);
|
||||||
return ((id.match("CAT:") && position == "over") ||
|
|
||||||
|
if (source_id.match("FEED:")) {
|
||||||
|
return ((id.match("CAT:") && position == "over") ||
|
||||||
(id.match("FEED:") && position != "over"));
|
(id.match("FEED:") && position != "over"));
|
||||||
} else if (source_id.match("CAT:")) {
|
} else if (source_id.match("CAT:")) {
|
||||||
return ((id.match("CAT:") && !id.match("CAT:0")) ||
|
return ((id.match("CAT:") && !id.match("CAT:0")) ||
|
||||||
(id.match("root") && position == "over"));
|
(id.match("root") && position == "over"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,96 +1,102 @@
|
|||||||
dojo.provide("fox.PrefFilterTree");
|
require(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) {
|
||||||
|
|
||||||
dojo.require("lib.CheckBoxTree");
|
return declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, {
|
||||||
dojo.require("dojo.data.ItemFileWriteStore");
|
|
||||||
|
|
||||||
dojo.declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, {
|
_saveEverything: function (saveCompleteCallback, saveFailedCallback,
|
||||||
|
newFileContentString) {
|
||||||
|
|
||||||
_saveEverything: function(saveCompleteCallback, saveFailedCallback,
|
dojo.xhrPost({
|
||||||
newFileContentString) {
|
url: "backend.php",
|
||||||
|
content: {
|
||||||
dojo.xhrPost({
|
op: "pref-filters", method: "savefilterorder",
|
||||||
url: "backend.php",
|
payload: newFileContentString
|
||||||
content: {op: "pref-filters", method: "savefilterorder",
|
},
|
||||||
payload: newFileContentString},
|
error: saveFailedCallback,
|
||||||
error: saveFailedCallback,
|
load: saveCompleteCallback
|
||||||
load: saveCompleteCallback});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, {
|
require(["dojo/_base/declare", "lib/CheckBoxTree"], function (declare) {
|
||||||
_createTreeNode: function(args) {
|
|
||||||
var tnode = this.inherited(arguments);
|
return declare("fox.PrefFilterTree", lib.CheckBoxTree, {
|
||||||
|
_createTreeNode: function(args) {
|
||||||
var enabled = this.model.store.getValue(args.item, 'enabled');
|
var tnode = this.inherited(arguments);
|
||||||
var param = this.model.store.getValue(args.item, 'param');
|
|
||||||
var rules = this.model.store.getValue(args.item, 'rules');
|
var enabled = this.model.store.getValue(args.item, 'enabled');
|
||||||
|
var param = this.model.store.getValue(args.item, 'param');
|
||||||
if (param) {
|
var rules = this.model.store.getValue(args.item, 'rules');
|
||||||
param = dojo.doc.createElement('span');
|
|
||||||
param.className = (enabled != false) ? 'labelParam' : 'labelParam filterDisabled';
|
if (param) {
|
||||||
param.innerHTML = args.item.param[0];
|
param = dojo.doc.createElement('span');
|
||||||
dojo.place(param, tnode.rowNode, 'first');
|
param.className = (enabled != false) ? 'labelParam' : 'labelParam filterDisabled';
|
||||||
}
|
param.innerHTML = args.item.param[0];
|
||||||
|
dojo.place(param, tnode.rowNode, 'first');
|
||||||
if (rules) {
|
}
|
||||||
param = dojo.doc.createElement('span');
|
|
||||||
param.className = 'filterRules';
|
if (rules) {
|
||||||
param.innerHTML = rules;
|
param = dojo.doc.createElement('span');
|
||||||
dojo.place(param, tnode.rowNode, 'next');
|
param.className = 'filterRules';
|
||||||
}
|
param.innerHTML = rules;
|
||||||
|
dojo.place(param, tnode.rowNode, 'next');
|
||||||
if (this.model.store.getValue(args.item, 'id') != 'root') {
|
}
|
||||||
var img = dojo.doc.createElement('img');
|
|
||||||
img.src ='images/filter.png';
|
if (this.model.store.getValue(args.item, 'id') != 'root') {
|
||||||
img.className = 'markedPic';
|
var img = dojo.doc.createElement('img');
|
||||||
tnode._filterIconNode = img;
|
img.src ='images/filter.png';
|
||||||
dojo.place(tnode._filterIconNode, tnode.labelNode, 'before');
|
img.className = 'markedPic';
|
||||||
}
|
tnode._filterIconNode = img;
|
||||||
|
dojo.place(tnode._filterIconNode, tnode.labelNode, 'before');
|
||||||
return tnode;
|
}
|
||||||
},
|
|
||||||
|
return tnode;
|
||||||
getLabel: function(item) {
|
},
|
||||||
var label = item.name;
|
|
||||||
|
getLabel: function(item) {
|
||||||
var feed = this.model.store.getValue(item, 'feed');
|
var label = item.name;
|
||||||
var inverse = this.model.store.getValue(item, 'inverse');
|
|
||||||
|
var feed = this.model.store.getValue(item, 'feed');
|
||||||
if (feed)
|
var inverse = this.model.store.getValue(item, 'inverse');
|
||||||
label += " (" + __("in") + " " + feed + ")";
|
|
||||||
|
if (feed)
|
||||||
if (inverse)
|
label += " (" + __("in") + " " + feed + ")";
|
||||||
label += " (" + __("Inverse") + ")";
|
|
||||||
|
if (inverse)
|
||||||
/* if (item.param)
|
label += " (" + __("Inverse") + ")";
|
||||||
label = "<span class=\"labelFixedLength\">" + label +
|
|
||||||
"</span>" + item.param[0]; */
|
/* if (item.param)
|
||||||
|
label = "<span class=\"labelFixedLength\">" + label +
|
||||||
return label;
|
"</span>" + item.param[0]; */
|
||||||
},
|
|
||||||
getIconClass: function (item, opened) {
|
return label;
|
||||||
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible";
|
},
|
||||||
},
|
getIconClass: function (item, opened) {
|
||||||
getLabelClass: function (item, opened) {
|
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible";
|
||||||
var enabled = this.model.store.getValue(item, 'enabled');
|
},
|
||||||
return (enabled != false) ? "dijitTreeLabel labelFixedLength" : "dijitTreeLabel labelFixedLength filterDisabled";
|
getLabelClass: function (item, opened) {
|
||||||
},
|
var enabled = this.model.store.getValue(item, 'enabled');
|
||||||
getRowClass: function (item, opened) {
|
return (enabled != false) ? "dijitTreeLabel labelFixedLength" : "dijitTreeLabel labelFixedLength filterDisabled";
|
||||||
return (!item.error || item.error == '') ? "dijitTreeRow" :
|
},
|
||||||
"dijitTreeRow Error";
|
getRowClass: function (item, opened) {
|
||||||
},
|
return (!item.error || item.error == '') ? "dijitTreeRow" :
|
||||||
checkItemAcceptance: function(target, source, position) {
|
"dijitTreeRow Error";
|
||||||
var item = dijit.getEnclosingWidget(target).item;
|
},
|
||||||
|
checkItemAcceptance: function(target, source, position) {
|
||||||
// disable copying items
|
var item = dijit.getEnclosingWidget(target).item;
|
||||||
source.copyState = function() { return false; };
|
|
||||||
|
// disable copying items
|
||||||
return position != 'over';
|
source.copyState = function() { return false; };
|
||||||
},
|
|
||||||
onDndDrop: function() {
|
return position != 'over';
|
||||||
this.inherited(arguments);
|
},
|
||||||
this.tree.model.store.save();
|
onDndDrop: function() {
|
||||||
},
|
this.inherited(arguments);
|
||||||
|
this.tree.model.store.save();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,43 +1,43 @@
|
|||||||
dojo.provide("fox.PrefLabelTree");
|
require(["dojo/_base/declare", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare) {
|
||||||
|
|
||||||
dojo.require("lib.CheckBoxTree");
|
return declare("fox.PrefLabelTree", lib.CheckBoxTree, {
|
||||||
dojo.require("dijit.form.DropDownButton");
|
setNameById: function (id, name) {
|
||||||
|
var item = this.model.store._itemsByIdentity['LABEL:' + id];
|
||||||
|
|
||||||
dojo.declare("fox.PrefLabelTree", lib.CheckBoxTree, {
|
if (item)
|
||||||
setNameById: function (id, name) {
|
this.model.store.setValue(item, 'name', name);
|
||||||
var item = this.model.store._itemsByIdentity['LABEL:' + id];
|
|
||||||
|
|
||||||
if (item)
|
},
|
||||||
this.model.store.setValue(item, 'name', name);
|
_createTreeNode: function(args) {
|
||||||
|
var tnode = this.inherited(arguments);
|
||||||
|
|
||||||
},
|
var fg_color = this.model.store.getValue(args.item, 'fg_color');
|
||||||
_createTreeNode: function(args) {
|
var bg_color = this.model.store.getValue(args.item, 'bg_color');
|
||||||
var tnode = this.inherited(arguments);
|
var type = this.model.store.getValue(args.item, 'type');
|
||||||
|
var bare_id = this.model.store.getValue(args.item, 'bare_id');
|
||||||
|
|
||||||
var fg_color = this.model.store.getValue(args.item, 'fg_color');
|
if (type == 'label') {
|
||||||
var bg_color = this.model.store.getValue(args.item, 'bg_color');
|
var span = dojo.doc.createElement('span');
|
||||||
var type = this.model.store.getValue(args.item, 'type');
|
span.innerHTML = 'α';
|
||||||
var bare_id = this.model.store.getValue(args.item, 'bare_id');
|
span.className = 'labelColorIndicator';
|
||||||
|
span.id = 'LICID-' + bare_id;
|
||||||
|
|
||||||
if (type == 'label') {
|
span.setStyle({
|
||||||
var span = dojo.doc.createElement('span');
|
color: fg_color,
|
||||||
span.innerHTML = 'α';
|
backgroundColor: bg_color});
|
||||||
span.className = 'labelColorIndicator';
|
|
||||||
span.id = 'LICID-' + bare_id;
|
|
||||||
|
|
||||||
span.setStyle({
|
tnode._labelIconNode = span;
|
||||||
color: fg_color,
|
|
||||||
backgroundColor: bg_color});
|
|
||||||
|
|
||||||
tnode._labelIconNode = span;
|
dojo.place(tnode._labelIconNode, tnode.labelNode, 'before');
|
||||||
|
}
|
||||||
|
|
||||||
dojo.place(tnode._labelIconNode, tnode.labelNode, 'before');
|
return tnode;
|
||||||
}
|
},
|
||||||
|
getIconClass: function (item, opened) {
|
||||||
|
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible";
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return tnode;
|
|
||||||
},
|
|
||||||
getIconClass: function (item, opened) {
|
|
||||||
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible";
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,474 +1,486 @@
|
|||||||
dojo.provide("lib.CheckBoxTree");
|
//dojo.provide("lib.CheckBoxTree");
|
||||||
dojo.provide("lib.CheckBoxStoreModel");
|
//dojo.provide("lib.CheckBoxStoreModel");
|
||||||
|
|
||||||
// THIS WIDGET IS BASED ON DOJO/DIJIT 1.4.0 AND WILL NOT WORK WITH PREVIOUS VERSIONS
|
// THIS WIDGET IS BASED ON DOJO/DIJIT 1.4.0 AND WILL NOT WORK WITH PREVIOUS VERSIONS
|
||||||
//
|
//
|
||||||
// Release date: 02/05/2010
|
// Release date: 02/05/2010
|
||||||
//
|
//
|
||||||
|
|
||||||
dojo.require("dijit.Tree");
|
//dojo.require("dijit.Tree");
|
||||||
dojo.require("dijit.form.CheckBox");
|
//dojo.require("dijit.form.CheckBox");
|
||||||
|
|
||||||
dojo.declare( "lib.CheckBoxStoreModel", dijit.tree.TreeStoreModel,
|
require(["dojo/_base/declare", "dijit/tree/TreeStoreModel"], function (declare) {
|
||||||
{
|
|
||||||
// checkboxAll: Boolean
|
return declare( "lib.CheckBoxStoreModel", dijit.tree.TreeStoreModel,
|
||||||
// If true, every node in the tree will receive a checkbox regardless if the 'checkbox' attribute
|
{
|
||||||
// is specified in the dojo.data.
|
// checkboxAll: Boolean
|
||||||
checkboxAll: true,
|
// If true, every node in the tree will receive a checkbox regardless if the 'checkbox' attribute
|
||||||
|
// is specified in the dojo.data.
|
||||||
// checkboxState: Boolean
|
checkboxAll: true,
|
||||||
// The default state applied to every checkbox unless otherwise specified in the dojo.data.
|
|
||||||
// (see also: checkboxIdent)
|
// checkboxState: Boolean
|
||||||
checkboxState: false,
|
// The default state applied to every checkbox unless otherwise specified in the dojo.data.
|
||||||
|
// (see also: checkboxIdent)
|
||||||
// checkboxRoot: Boolean
|
checkboxState: false,
|
||||||
// If true, the root node will receive a checkbox eventhough it's not a true entry in the store.
|
|
||||||
// This attribute is independent of the showRoot attribute of the tree itself. If the tree
|
// checkboxRoot: Boolean
|
||||||
// attribute 'showRoot' is set to false to checkbox for the root will not show either.
|
// If true, the root node will receive a checkbox eventhough it's not a true entry in the store.
|
||||||
checkboxRoot: false,
|
// This attribute is independent of the showRoot attribute of the tree itself. If the tree
|
||||||
|
// attribute 'showRoot' is set to false to checkbox for the root will not show either.
|
||||||
// checkboxStrict: Boolean
|
checkboxRoot: false,
|
||||||
// If true, a strict parent-child checkbox relation is maintained. For example, if all children
|
|
||||||
// are checked the parent will automatically be checked or if any of the children are unchecked
|
// checkboxStrict: Boolean
|
||||||
// the parent will be unchecked.
|
// If true, a strict parent-child checkbox relation is maintained. For example, if all children
|
||||||
checkboxStrict: true,
|
// are checked the parent will automatically be checked or if any of the children are unchecked
|
||||||
|
// the parent will be unchecked.
|
||||||
// checkboxIdent: String
|
checkboxStrict: true,
|
||||||
// The attribute name (attribute of the dojo.data.item) that specifies that items checkbox initial
|
|
||||||
// state. Example: { name:'Egypt', type:'country', checkbox: true }
|
// checkboxIdent: String
|
||||||
// If a dojo.data.item has no 'checkbox' attribute specified it will depend on the attribute
|
// The attribute name (attribute of the dojo.data.item) that specifies that items checkbox initial
|
||||||
// 'checkboxAll' if one will be created automatically and if so what the initial state will be as
|
// state. Example: { name:'Egypt', type:'country', checkbox: true }
|
||||||
// specified by 'checkboxState'.
|
// If a dojo.data.item has no 'checkbox' attribute specified it will depend on the attribute
|
||||||
checkboxIdent: "checkbox",
|
// 'checkboxAll' if one will be created automatically and if so what the initial state will be as
|
||||||
|
// specified by 'checkboxState'.
|
||||||
updateCheckbox: function(/*dojo.data.Item*/ storeItem, /*Boolean*/ newState ) {
|
checkboxIdent: "checkbox",
|
||||||
// summary:
|
|
||||||
// Update the checkbox state (true/false) for the item and the associated parent and
|
updateCheckbox: function(/*dojo.data.Item*/ storeItem, /*Boolean*/ newState ) {
|
||||||
// child checkboxes if any.
|
// summary:
|
||||||
// description:
|
// Update the checkbox state (true/false) for the item and the associated parent and
|
||||||
// Update a single checkbox state (true/false) for the item and the associated parent
|
// child checkboxes if any.
|
||||||
// and child checkboxes if any. This function is called from the tree if a user checked
|
// description:
|
||||||
// or unchecked a checkbox on the tree. The parent and child tree nodes are updated to
|
// Update a single checkbox state (true/false) for the item and the associated parent
|
||||||
// maintain consistency if 'checkboxStrict' is set to true.
|
// and child checkboxes if any. This function is called from the tree if a user checked
|
||||||
// storeItem:
|
// or unchecked a checkbox on the tree. The parent and child tree nodes are updated to
|
||||||
// The item in the dojo.data.store whos checkbox state needs updating.
|
// maintain consistency if 'checkboxStrict' is set to true.
|
||||||
// newState:
|
// storeItem:
|
||||||
// The new state of the checkbox: true or false
|
// The item in the dojo.data.store whos checkbox state needs updating.
|
||||||
// example:
|
// newState:
|
||||||
// | model.updateCheckboxState(item, true);
|
// The new state of the checkbox: true or false
|
||||||
//
|
// example:
|
||||||
|
// | model.updateCheckboxState(item, true);
|
||||||
this._setCheckboxState( storeItem, newState );
|
//
|
||||||
//if( this.checkboxStrict ) { I don't need all this 1-1 stuff, only parent -> child (fox)
|
|
||||||
this._updateChildCheckbox( storeItem, newState );
|
this._setCheckboxState( storeItem, newState );
|
||||||
//this._updateParentCheckbox( storeItem, newState );
|
//if( this.checkboxStrict ) { I don't need all this 1-1 stuff, only parent -> child (fox)
|
||||||
//}
|
this._updateChildCheckbox( storeItem, newState );
|
||||||
},
|
//this._updateParentCheckbox( storeItem, newState );
|
||||||
setAllChecked: function(checked) {
|
//}
|
||||||
var items = this.store._arrayOfAllItems;
|
},
|
||||||
this.setCheckboxState(items, checked);
|
setAllChecked: function(checked) {
|
||||||
},
|
var items = this.store._arrayOfAllItems;
|
||||||
setCheckboxState: function(items, checked) {
|
this.setCheckboxState(items, checked);
|
||||||
for (var i = 0; i < items.length; i++) {
|
},
|
||||||
this._setCheckboxState(items[i], checked);
|
setCheckboxState: function(items, checked) {
|
||||||
}
|
for (var i = 0; i < items.length; i++) {
|
||||||
},
|
this._setCheckboxState(items[i], checked);
|
||||||
getCheckedItems: function() {
|
|
||||||
var items = this.store._arrayOfAllItems;
|
|
||||||
var result = [];
|
|
||||||
|
|
||||||
for (var i = 0; i < items.length; i++) {
|
|
||||||
if (this.store.getValue(items[i], 'checkbox'))
|
|
||||||
result.push(items[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
getCheckboxState: function(/*dojo.data.Item*/ storeItem) {
|
|
||||||
// summary:
|
|
||||||
// Get the current checkbox state from the dojo.data.store.
|
|
||||||
// description:
|
|
||||||
// Get the current checkbox state from the dojo.data store. A checkbox can have three
|
|
||||||
// different states: true, false or undefined. Undefined in this context means no
|
|
||||||
// checkbox identifier (checkboxIdent) was found in the dojo.data store. Depending on
|
|
||||||
// the checkbox attributes as specified above the following will take place:
|
|
||||||
// a) If the current checkbox state is undefined and the checkbox attribute 'checkboxAll' or
|
|
||||||
// 'checkboxRoot' is true one will be created and the default state 'checkboxState' will
|
|
||||||
// be applied.
|
|
||||||
// b) If the current state is undefined and 'checkboxAll' is false the state undefined remains
|
|
||||||
// unchanged and is returned. This will prevent any tree node from creating a checkbox.
|
|
||||||
//
|
|
||||||
// storeItem:
|
|
||||||
// The item in the dojo.data.store whos checkbox state is returned.
|
|
||||||
// example:
|
|
||||||
// | var currState = model.getCheckboxState(item);
|
|
||||||
//
|
|
||||||
var currState = undefined;
|
|
||||||
|
|
||||||
// Special handling required for the 'fake' root entry (the root is NOT a dojo.data.item).
|
|
||||||
// this stuff is only relevant for Forest store -fox
|
|
||||||
/* if ( storeItem == this.root ) {
|
|
||||||
if( typeof(storeItem.checkbox) == "undefined" ) {
|
|
||||||
this.root.checkbox = undefined; // create a new checbox reference as undefined.
|
|
||||||
if( this.checkboxRoot ) {
|
|
||||||
currState = this.root.checkbox = this.checkboxState;
|
|
||||||
}
|
}
|
||||||
} else {
|
},
|
||||||
currState = this.root.checkbox;
|
getCheckedItems: function() {
|
||||||
}
|
var items = this.store._arrayOfAllItems;
|
||||||
} else { // a valid dojo.store.item
|
var result = [];
|
||||||
currState = this.store.getValue(storeItem, this.checkboxIdent);
|
|
||||||
if( currState == undefined && this.checkboxAll) {
|
for (var i = 0; i < items.length; i++) {
|
||||||
this._setCheckboxState( storeItem, this.checkboxState );
|
if (this.store.getValue(items[i], 'checkbox'))
|
||||||
currState = this.checkboxState;
|
result.push(items[i]);
|
||||||
}
|
}
|
||||||
} */
|
|
||||||
|
return result;
|
||||||
currState = this.store.getValue(storeItem, this.checkboxIdent);
|
},
|
||||||
if( currState == undefined && this.checkboxAll) {
|
|
||||||
this._setCheckboxState( storeItem, this.checkboxState );
|
getCheckboxState: function(/*dojo.data.Item*/ storeItem) {
|
||||||
currState = this.checkboxState;
|
// summary:
|
||||||
}
|
// Get the current checkbox state from the dojo.data.store.
|
||||||
|
// description:
|
||||||
return currState; // the current state of the checkbox (true/false or undefined)
|
// Get the current checkbox state from the dojo.data store. A checkbox can have three
|
||||||
},
|
// different states: true, false or undefined. Undefined in this context means no
|
||||||
|
// checkbox identifier (checkboxIdent) was found in the dojo.data store. Depending on
|
||||||
_setCheckboxState: function(/*dojo.data.Item*/ storeItem, /*Boolean*/ newState ) {
|
// the checkbox attributes as specified above the following will take place:
|
||||||
// summary:
|
// a) If the current checkbox state is undefined and the checkbox attribute 'checkboxAll' or
|
||||||
// Set/update the checkbox state on the dojo.data store.
|
// 'checkboxRoot' is true one will be created and the default state 'checkboxState' will
|
||||||
// description:
|
// be applied.
|
||||||
// Set/update the checkbox state on the dojo.data.store. Retreive the current
|
// b) If the current state is undefined and 'checkboxAll' is false the state undefined remains
|
||||||
// state of the checkbox and validate if an update is required, this will keep
|
// unchanged and is returned. This will prevent any tree node from creating a checkbox.
|
||||||
// update events to a minimum. On completion a 'onCheckboxChange' event is
|
//
|
||||||
// triggered.
|
// storeItem:
|
||||||
// If the current state is undefined (ie: no checkbox attribute specified for
|
// The item in the dojo.data.store whos checkbox state is returned.
|
||||||
// this dojo.data.item) the 'checkboxAll' attribute is checked to see if one
|
// example:
|
||||||
// needs to be created. In case of the root the 'checkboxRoot' attribute is checked.
|
// | var currState = model.getCheckboxState(item);
|
||||||
// NOTE: the store.setValue function will create the 'checkbox' attribute for the
|
//
|
||||||
// item if none exists.
|
var currState = undefined;
|
||||||
// storeItem:
|
|
||||||
// The item in the dojo.data.store whos checkbox state is updated.
|
// Special handling required for the 'fake' root entry (the root is NOT a dojo.data.item).
|
||||||
// newState:
|
// this stuff is only relevant for Forest store -fox
|
||||||
// The new state of the checkbox: true or false
|
/* if ( storeItem == this.root ) {
|
||||||
// example:
|
if( typeof(storeItem.checkbox) == "undefined" ) {
|
||||||
// | model.setCheckboxState(item, true);
|
this.root.checkbox = undefined; // create a new checbox reference as undefined.
|
||||||
//
|
if( this.checkboxRoot ) {
|
||||||
var stateChanged = true;
|
currState = this.root.checkbox = this.checkboxState;
|
||||||
|
}
|
||||||
if( storeItem != this.root ) {
|
} else {
|
||||||
var currState = this.store.getValue(storeItem, this.checkboxIdent);
|
currState = this.root.checkbox;
|
||||||
if( currState != newState && ( currState !== undefined || this.checkboxAll ) ) {
|
}
|
||||||
this.store.setValue(storeItem, this.checkboxIdent, newState);
|
} else { // a valid dojo.store.item
|
||||||
} else {
|
currState = this.store.getValue(storeItem, this.checkboxIdent);
|
||||||
stateChanged = false; // No changes to the checkbox
|
if( currState == undefined && this.checkboxAll) {
|
||||||
}
|
this._setCheckboxState( storeItem, this.checkboxState );
|
||||||
} else { // Tree root instance
|
currState = this.checkboxState;
|
||||||
if( this.root.checkbox != newState && ( this.root.checkbox !== undefined || this.checkboxRoot ) ) {
|
}
|
||||||
this.root.checkbox = newState;
|
} */
|
||||||
} else {
|
|
||||||
stateChanged = false;
|
currState = this.store.getValue(storeItem, this.checkboxIdent);
|
||||||
}
|
if( currState == undefined && this.checkboxAll) {
|
||||||
}
|
this._setCheckboxState( storeItem, this.checkboxState );
|
||||||
if( stateChanged ) { // In case of any changes trigger the update event.
|
currState = this.checkboxState;
|
||||||
this.onCheckboxChange(storeItem);
|
}
|
||||||
}
|
|
||||||
return stateChanged;
|
return currState; // the current state of the checkbox (true/false or undefined)
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateChildCheckbox: function(/*dojo.data.Item*/ parentItem, /*Boolean*/ newState ) {
|
_setCheckboxState: function(/*dojo.data.Item*/ storeItem, /*Boolean*/ newState ) {
|
||||||
// summary:
|
// summary:
|
||||||
// Set all child checkboxes to true/false depending on the parent checkbox state.
|
// Set/update the checkbox state on the dojo.data store.
|
||||||
// description:
|
// description:
|
||||||
// If a parent checkbox changes state, all child and grandchild checkboxes will be
|
// Set/update the checkbox state on the dojo.data.store. Retreive the current
|
||||||
// updated to reflect the change. For example, if the parent state is set to true,
|
// state of the checkbox and validate if an update is required, this will keep
|
||||||
// all child and grandchild checkboxes will receive that same 'true' state.
|
// update events to a minimum. On completion a 'onCheckboxChange' event is
|
||||||
// If a child checkbox changes state and has multiple parent, all of its parents
|
// triggered.
|
||||||
// need to be re-evaluated.
|
// If the current state is undefined (ie: no checkbox attribute specified for
|
||||||
// parentItem:
|
// this dojo.data.item) the 'checkboxAll' attribute is checked to see if one
|
||||||
// The parent dojo.data.item whos child/grandchild checkboxes require updating.
|
// needs to be created. In case of the root the 'checkboxRoot' attribute is checked.
|
||||||
// newState:
|
// NOTE: the store.setValue function will create the 'checkbox' attribute for the
|
||||||
// The new state of the checkbox: true or false
|
// item if none exists.
|
||||||
//
|
// storeItem:
|
||||||
|
// The item in the dojo.data.store whos checkbox state is updated.
|
||||||
if( this.mayHaveChildren( parentItem )) {
|
// newState:
|
||||||
this.getChildren( parentItem, dojo.hitch( this,
|
// The new state of the checkbox: true or false
|
||||||
function( children ) {
|
// example:
|
||||||
dojo.forEach( children, function(child) {
|
// | model.setCheckboxState(item, true);
|
||||||
if( this._setCheckboxState(child, newState) ) {
|
//
|
||||||
var parents = this._getParentsItem(child);
|
var stateChanged = true;
|
||||||
if( parents.length > 1 ) {
|
|
||||||
this._updateParentCheckbox( child, newState );
|
if( storeItem != this.root ) {
|
||||||
}
|
var currState = this.store.getValue(storeItem, this.checkboxIdent);
|
||||||
|
if( currState != newState && ( currState !== undefined || this.checkboxAll ) ) {
|
||||||
|
this.store.setValue(storeItem, this.checkboxIdent, newState);
|
||||||
|
} else {
|
||||||
|
stateChanged = false; // No changes to the checkbox
|
||||||
|
}
|
||||||
|
} else { // Tree root instance
|
||||||
|
if( this.root.checkbox != newState && ( this.root.checkbox !== undefined || this.checkboxRoot ) ) {
|
||||||
|
this.root.checkbox = newState;
|
||||||
|
} else {
|
||||||
|
stateChanged = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( stateChanged ) { // In case of any changes trigger the update event.
|
||||||
|
this.onCheckboxChange(storeItem);
|
||||||
|
}
|
||||||
|
return stateChanged;
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateChildCheckbox: function(/*dojo.data.Item*/ parentItem, /*Boolean*/ newState ) {
|
||||||
|
// summary:
|
||||||
|
// Set all child checkboxes to true/false depending on the parent checkbox state.
|
||||||
|
// description:
|
||||||
|
// If a parent checkbox changes state, all child and grandchild checkboxes will be
|
||||||
|
// updated to reflect the change. For example, if the parent state is set to true,
|
||||||
|
// all child and grandchild checkboxes will receive that same 'true' state.
|
||||||
|
// If a child checkbox changes state and has multiple parent, all of its parents
|
||||||
|
// need to be re-evaluated.
|
||||||
|
// parentItem:
|
||||||
|
// The parent dojo.data.item whos child/grandchild checkboxes require updating.
|
||||||
|
// newState:
|
||||||
|
// The new state of the checkbox: true or false
|
||||||
|
//
|
||||||
|
|
||||||
|
if( this.mayHaveChildren( parentItem )) {
|
||||||
|
this.getChildren( parentItem, dojo.hitch( this,
|
||||||
|
function( children ) {
|
||||||
|
dojo.forEach( children, function(child) {
|
||||||
|
if( this._setCheckboxState(child, newState) ) {
|
||||||
|
var parents = this._getParentsItem(child);
|
||||||
|
if( parents.length > 1 ) {
|
||||||
|
this._updateParentCheckbox( child, newState );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( this.mayHaveChildren( child )) {
|
||||||
|
this._updateChildCheckbox( child, newState );
|
||||||
|
}
|
||||||
|
}, this );
|
||||||
|
}),
|
||||||
|
function(err) {
|
||||||
|
console.error(this, ": updating child checkboxes: ", err);
|
||||||
}
|
}
|
||||||
if( this.mayHaveChildren( child )) {
|
);
|
||||||
this._updateChildCheckbox( child, newState );
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateParentCheckbox: function(/*dojo.data.Item*/ storeItem, /*Boolean*/ newState ) {
|
||||||
|
// summary:
|
||||||
|
// Update the parent checkbox state depending on the state of all child checkboxes.
|
||||||
|
// description:
|
||||||
|
// Update the parent checkbox state depending on the state of all child checkboxes.
|
||||||
|
// The parent checkbox automatically changes state if ALL child checkboxes are true
|
||||||
|
// or false. If, as a result, the parent checkbox changes state, we will check if
|
||||||
|
// its parent needs to be updated as well all the way upto the root.
|
||||||
|
// storeItem:
|
||||||
|
// The dojo.data.item whos parent checkboxes require updating.
|
||||||
|
// newState:
|
||||||
|
// The new state of the checkbox: true or false
|
||||||
|
//
|
||||||
|
var parents = this._getParentsItem(storeItem);
|
||||||
|
dojo.forEach( parents, function( parentItem ) {
|
||||||
|
if( newState ) { // new state = true (checked)
|
||||||
|
this.getChildren( parentItem, dojo.hitch( this,
|
||||||
|
function(siblings) {
|
||||||
|
var allChecked = true;
|
||||||
|
dojo.some( siblings, function(sibling) {
|
||||||
|
siblState = this.getCheckboxState(sibling);
|
||||||
|
if( siblState !== undefined && allChecked )
|
||||||
|
allChecked = siblState;
|
||||||
|
return !(allChecked);
|
||||||
|
}, this );
|
||||||
|
if( allChecked ) {
|
||||||
|
this._setCheckboxState( parentItem, true );
|
||||||
|
this._updateParentCheckbox( parentItem, true );
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
function(err) {
|
||||||
|
console.error(this, ": updating parent checkboxes: ", err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else { // new state = false (unchecked)
|
||||||
|
if( this._setCheckboxState( parentItem, false ) ) {
|
||||||
|
this._updateParentCheckbox( parentItem, false );
|
||||||
}
|
}
|
||||||
}, this );
|
}
|
||||||
}),
|
}, this );
|
||||||
function(err) {
|
},
|
||||||
console.error(this, ": updating child checkboxes: ", err);
|
|
||||||
|
_getParentsItem: function(/*dojo.data.Item*/ storeItem ) {
|
||||||
|
// summary:
|
||||||
|
// Get the parent(s) of a dojo.data item.
|
||||||
|
// description:
|
||||||
|
// Get the parent(s) of a dojo.data item. The '_reverseRefMap' entry of the item is
|
||||||
|
// used to identify the parent(s). A child will have a parent reference if the parent
|
||||||
|
// specified the '_reference' attribute.
|
||||||
|
// For example: children:[{_reference:'Mexico'}, {_reference:'Canada'}, ...
|
||||||
|
// storeItem:
|
||||||
|
// The dojo.data.item whos parent(s) will be returned.
|
||||||
|
//
|
||||||
|
var parents = [];
|
||||||
|
|
||||||
|
if( storeItem != this.root ) {
|
||||||
|
var references = storeItem[this.store._reverseRefMap];
|
||||||
|
for(itemId in references ) {
|
||||||
|
parents.push(this.store._itemsByIdentity[itemId]);
|
||||||
|
}
|
||||||
|
if (!parents.length) {
|
||||||
|
parents.push(this.root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
return parents; // parent(s) of a dojo.data.item (Array of dojo.data.items)
|
||||||
}
|
},
|
||||||
},
|
|
||||||
|
validateData: function(/*dojo.data.Item*/ storeItem, /*thisObject*/ scope ) {
|
||||||
_updateParentCheckbox: function(/*dojo.data.Item*/ storeItem, /*Boolean*/ newState ) {
|
// summary:
|
||||||
// summary:
|
// Validate/normalize the parent(s) checkbox data in the dojo.data store.
|
||||||
// Update the parent checkbox state depending on the state of all child checkboxes.
|
// description:
|
||||||
// description:
|
// Validate/normalize the parent-child checkbox relationship if the attribute
|
||||||
// Update the parent checkbox state depending on the state of all child checkboxes.
|
// 'checkboxStrict' is set to true. This function is called as part of the post
|
||||||
// The parent checkbox automatically changes state if ALL child checkboxes are true
|
// creation of the Tree instance. All parent checkboxes are set to the appropriate
|
||||||
// or false. If, as a result, the parent checkbox changes state, we will check if
|
// state according to the actual state(s) of their children.
|
||||||
// its parent needs to be updated as well all the way upto the root.
|
// This will potentionally overwrite whatever was specified for the parent in the
|
||||||
// storeItem:
|
// dojo.data store. This will garantee the tree is in a consistent state after startup.
|
||||||
// The dojo.data.item whos parent checkboxes require updating.
|
// storeItem:
|
||||||
// newState:
|
// The element to start traversing the dojo.data.store, typically model.root
|
||||||
// The new state of the checkbox: true or false
|
// scope:
|
||||||
//
|
// The scope to use when this method executes.
|
||||||
var parents = this._getParentsItem(storeItem);
|
// example:
|
||||||
dojo.forEach( parents, function( parentItem ) {
|
// | this.model.validateData(this.model.root, this.model);
|
||||||
if( newState ) { // new state = true (checked)
|
//
|
||||||
this.getChildren( parentItem, dojo.hitch( this,
|
if( !scope.checkboxStrict ) {
|
||||||
function(siblings) {
|
return;
|
||||||
|
}
|
||||||
|
scope.getChildren( storeItem, dojo.hitch( scope,
|
||||||
|
function(children) {
|
||||||
var allChecked = true;
|
var allChecked = true;
|
||||||
dojo.some( siblings, function(sibling) {
|
var childState;
|
||||||
siblState = this.getCheckboxState(sibling);
|
dojo.forEach( children, function( child ) {
|
||||||
if( siblState !== undefined && allChecked )
|
if( this.mayHaveChildren( child )) {
|
||||||
allChecked = siblState;
|
this.validateData( child, this );
|
||||||
return !(allChecked);
|
}
|
||||||
}, this );
|
childState = this.getCheckboxState( child );
|
||||||
if( allChecked ) {
|
if( childState !== undefined && allChecked )
|
||||||
this._setCheckboxState( parentItem, true );
|
allChecked = childState;
|
||||||
this._updateParentCheckbox( parentItem, true );
|
}, this);
|
||||||
|
|
||||||
|
if ( this._setCheckboxState( storeItem, allChecked) ) {
|
||||||
|
this._updateParentCheckbox( storeItem, allChecked);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
function(err) {
|
function(err) {
|
||||||
console.error(this, ": updating parent checkboxes: ", err);
|
console.error(this, ": validating checkbox data: ", err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else { // new state = false (unchecked)
|
},
|
||||||
if( this._setCheckboxState( parentItem, false ) ) {
|
|
||||||
this._updateParentCheckbox( parentItem, false );
|
onCheckboxChange: function(/*dojo.data.Item*/ storeItem ) {
|
||||||
}
|
// summary:
|
||||||
}
|
// Callback whenever a checkbox state has changed state, so that
|
||||||
}, this );
|
// the Tree can update the checkbox. This callback is generally
|
||||||
},
|
// triggered by the '_setCheckboxState' function.
|
||||||
|
// tags:
|
||||||
_getParentsItem: function(/*dojo.data.Item*/ storeItem ) {
|
// callback
|
||||||
// summary:
|
|
||||||
// Get the parent(s) of a dojo.data item.
|
|
||||||
// description:
|
|
||||||
// Get the parent(s) of a dojo.data item. The '_reverseRefMap' entry of the item is
|
|
||||||
// used to identify the parent(s). A child will have a parent reference if the parent
|
|
||||||
// specified the '_reference' attribute.
|
|
||||||
// For example: children:[{_reference:'Mexico'}, {_reference:'Canada'}, ...
|
|
||||||
// storeItem:
|
|
||||||
// The dojo.data.item whos parent(s) will be returned.
|
|
||||||
//
|
|
||||||
var parents = [];
|
|
||||||
|
|
||||||
if( storeItem != this.root ) {
|
|
||||||
var references = storeItem[this.store._reverseRefMap];
|
|
||||||
for(itemId in references ) {
|
|
||||||
parents.push(this.store._itemsByIdentity[itemId]);
|
|
||||||
}
|
}
|
||||||
if (!parents.length) {
|
|
||||||
parents.push(this.root);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return parents; // parent(s) of a dojo.data.item (Array of dojo.data.items)
|
|
||||||
},
|
|
||||||
|
|
||||||
validateData: function(/*dojo.data.Item*/ storeItem, /*thisObject*/ scope ) {
|
|
||||||
// summary:
|
|
||||||
// Validate/normalize the parent(s) checkbox data in the dojo.data store.
|
|
||||||
// description:
|
|
||||||
// Validate/normalize the parent-child checkbox relationship if the attribute
|
|
||||||
// 'checkboxStrict' is set to true. This function is called as part of the post
|
|
||||||
// creation of the Tree instance. All parent checkboxes are set to the appropriate
|
|
||||||
// state according to the actual state(s) of their children.
|
|
||||||
// This will potentionally overwrite whatever was specified for the parent in the
|
|
||||||
// dojo.data store. This will garantee the tree is in a consistent state after startup.
|
|
||||||
// storeItem:
|
|
||||||
// The element to start traversing the dojo.data.store, typically model.root
|
|
||||||
// scope:
|
|
||||||
// The scope to use when this method executes.
|
|
||||||
// example:
|
|
||||||
// | this.model.validateData(this.model.root, this.model);
|
|
||||||
//
|
|
||||||
if( !scope.checkboxStrict ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
scope.getChildren( storeItem, dojo.hitch( scope,
|
|
||||||
function(children) {
|
|
||||||
var allChecked = true;
|
|
||||||
var childState;
|
|
||||||
dojo.forEach( children, function( child ) {
|
|
||||||
if( this.mayHaveChildren( child )) {
|
|
||||||
this.validateData( child, this );
|
|
||||||
}
|
|
||||||
childState = this.getCheckboxState( child );
|
|
||||||
if( childState !== undefined && allChecked )
|
|
||||||
allChecked = childState;
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
if ( this._setCheckboxState( storeItem, allChecked) ) {
|
});
|
||||||
this._updateParentCheckbox( storeItem, allChecked);
|
|
||||||
|
});
|
||||||
|
|
||||||
|
require(["dojo/_base/declare", "dijit/Tree"], function (declare) {
|
||||||
|
|
||||||
|
return declare("lib._CheckBoxTreeNode", dijit._TreeNode,
|
||||||
|
{
|
||||||
|
// _checkbox: [protected] dojo.doc.element
|
||||||
|
// Local reference to the dojo.doc.element of type 'checkbox'
|
||||||
|
_checkbox: null,
|
||||||
|
|
||||||
|
_createCheckbox: function () {
|
||||||
|
// summary:
|
||||||
|
// Create a checkbox on the CheckBoxTreeNode
|
||||||
|
// description:
|
||||||
|
// Create a checkbox on the CheckBoxTreeNode. The checkbox is ONLY created if a
|
||||||
|
// valid reference was found in the dojo.data store or the attribute 'checkboxAll'
|
||||||
|
// is set to true. If the current state is 'undefined' no reference was found and
|
||||||
|
// 'checkboxAll' is set to false.
|
||||||
|
// Note: the attribute 'checkboxAll' is validated by the getCheckboxState function
|
||||||
|
// therefore no need to do that here. (see getCheckboxState for details).
|
||||||
|
//
|
||||||
|
var currState = this.tree.model.getCheckboxState(this.item);
|
||||||
|
if (currState !== undefined) {
|
||||||
|
this._checkbox = new dijit.form.CheckBox();
|
||||||
|
//this._checkbox = dojo.doc.createElement('input');
|
||||||
|
this._checkbox.type = 'checkbox';
|
||||||
|
this._checkbox.attr('checked', currState);
|
||||||
|
dojo.place(this._checkbox.domNode, this.expandoNode, 'after');
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
function(err) {
|
|
||||||
console.error(this, ": validating checkbox data: ", err);
|
postCreate: function () {
|
||||||
|
// summary:
|
||||||
|
// Handle the creation of the checkbox after the CheckBoxTreeNode has been instanciated.
|
||||||
|
// description:
|
||||||
|
// Handle the creation of the checkbox after the CheckBoxTreeNode has been instanciated.
|
||||||
|
this._createCheckbox();
|
||||||
|
this.inherited(arguments);
|
||||||
}
|
}
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
onCheckboxChange: function(/*dojo.data.Item*/ storeItem ) {
|
|
||||||
// summary:
|
|
||||||
// Callback whenever a checkbox state has changed state, so that
|
|
||||||
// the Tree can update the checkbox. This callback is generally
|
|
||||||
// triggered by the '_setCheckboxState' function.
|
|
||||||
// tags:
|
|
||||||
// callback
|
|
||||||
}
|
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.declare( "lib._CheckBoxTreeNode", dijit._TreeNode,
|
require(["dojo/_base/declare", "dijit/Tree"], function (declare) {
|
||||||
{
|
|
||||||
// _checkbox: [protected] dojo.doc.element
|
return declare( "lib.CheckBoxTree", dijit.Tree,
|
||||||
// Local reference to the dojo.doc.element of type 'checkbox'
|
{
|
||||||
_checkbox: null,
|
|
||||||
|
onNodeChecked: function(/*dojo.data.Item*/ storeItem, /*treeNode*/ treeNode) {
|
||||||
_createCheckbox: function() {
|
// summary:
|
||||||
// summary:
|
// Callback when a checkbox tree node is checked
|
||||||
// Create a checkbox on the CheckBoxTreeNode
|
// tags:
|
||||||
// description:
|
// callback
|
||||||
// Create a checkbox on the CheckBoxTreeNode. The checkbox is ONLY created if a
|
},
|
||||||
// valid reference was found in the dojo.data store or the attribute 'checkboxAll'
|
|
||||||
// is set to true. If the current state is 'undefined' no reference was found and
|
onNodeUnchecked: function(/*dojo.data.Item*/ storeItem, /* treeNode */ treeNode) {
|
||||||
// 'checkboxAll' is set to false.
|
// summary:
|
||||||
// Note: the attribute 'checkboxAll' is validated by the getCheckboxState function
|
// Callback when a checkbox tree node is unchecked
|
||||||
// therefore no need to do that here. (see getCheckboxState for details).
|
// tags:
|
||||||
//
|
// callback
|
||||||
var currState = this.tree.model.getCheckboxState( this.item );
|
},
|
||||||
if( currState !== undefined ) {
|
|
||||||
this._checkbox = new dijit.form.CheckBox();
|
_onClick: function(/*TreeNode*/ nodeWidget, /*Event*/ e) {
|
||||||
//this._checkbox = dojo.doc.createElement('input');
|
// summary:
|
||||||
this._checkbox.type = 'checkbox';
|
// Translates click events into commands for the controller to process
|
||||||
this._checkbox.attr('checked', currState);
|
// description:
|
||||||
dojo.place(this._checkbox.domNode, this.expandoNode, 'after');
|
// the _onClick function is called whenever a 'click' is detected. This
|
||||||
}
|
// instance of _onClick only handles the click events associated with
|
||||||
},
|
// the checkbox whos DOM name is INPUT.
|
||||||
|
//
|
||||||
postCreate: function() {
|
var domElement = e.target;
|
||||||
// summary:
|
|
||||||
// Handle the creation of the checkbox after the CheckBoxTreeNode has been instanciated.
|
// Only handle checkbox clicks here
|
||||||
// description:
|
if(domElement.type != 'checkbox') {
|
||||||
// Handle the creation of the checkbox after the CheckBoxTreeNode has been instanciated.
|
return this.inherited( arguments );
|
||||||
this._createCheckbox();
|
}
|
||||||
this.inherited( arguments );
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
this._publish("execute", { item: nodeWidget.item, node: nodeWidget} );
|
||||||
|
// Go tell the model to update the checkbox state
|
||||||
|
|
||||||
dojo.declare( "lib.CheckBoxTree", dijit.Tree,
|
this.model.updateCheckbox( nodeWidget.item, nodeWidget._checkbox.checked );
|
||||||
{
|
// Generate some additional events
|
||||||
|
//this.onClick( nodeWidget.item, nodeWidget, e );
|
||||||
onNodeChecked: function(/*dojo.data.Item*/ storeItem, /*treeNode*/ treeNode) {
|
if(nodeWidget._checkbox.checked) {
|
||||||
// summary:
|
this.onNodeChecked( nodeWidget.item, nodeWidget);
|
||||||
// Callback when a checkbox tree node is checked
|
} else {
|
||||||
// tags:
|
this.onNodeUnchecked( nodeWidget.item, nodeWidget);
|
||||||
// callback
|
}
|
||||||
},
|
this.focusNode(nodeWidget);
|
||||||
|
},
|
||||||
onNodeUnchecked: function(/*dojo.data.Item*/ storeItem, /* treeNode */ treeNode) {
|
|
||||||
// summary:
|
_onCheckboxChange: function(/*dojo.data.Item*/ storeItem ) {
|
||||||
// Callback when a checkbox tree node is unchecked
|
// summary:
|
||||||
// tags:
|
// Processes notification of a change to a checkbox state (triggered by the model).
|
||||||
// callback
|
// description:
|
||||||
},
|
// Whenever the model changes the state of a checkbox in the dojo.data.store it will
|
||||||
|
// trigger the 'onCheckboxChange' event allowing the Tree to make the same changes
|
||||||
_onClick: function(/*TreeNode*/ nodeWidget, /*Event*/ e) {
|
// on the tree Node. There are several conditions why a tree node or checkbox does not
|
||||||
// summary:
|
// exists:
|
||||||
// Translates click events into commands for the controller to process
|
// a) The node has not been created yet (the user has not expanded the tree node yet).
|
||||||
// description:
|
// b) The checkbox may be null if condition (a) exists or no 'checkbox' attribute was
|
||||||
// the _onClick function is called whenever a 'click' is detected. This
|
// specified for the associated dojo.data.item and the attribute 'checkboxAll' is
|
||||||
// instance of _onClick only handles the click events associated with
|
// set to false.
|
||||||
// the checkbox whos DOM name is INPUT.
|
// tags:
|
||||||
//
|
// callback
|
||||||
var domElement = e.target;
|
var model = this.model,
|
||||||
|
identity = model.getIdentity(storeItem),
|
||||||
// Only handle checkbox clicks here
|
nodes = this._itemNodesMap[identity];
|
||||||
if(domElement.type != 'checkbox') {
|
|
||||||
return this.inherited( arguments );
|
// As of dijit.Tree 1.4 multiple references (parents) are supported, therefore we may have
|
||||||
}
|
// to update multiple nodes which are all associated with the same dojo.data.item.
|
||||||
|
if( nodes ) {
|
||||||
this._publish("execute", { item: nodeWidget.item, node: nodeWidget} );
|
dojo.forEach( nodes, function(node) {
|
||||||
// Go tell the model to update the checkbox state
|
if( node._checkbox != null ) {
|
||||||
|
node._checkbox.attr('checked', this.model.getCheckboxState( storeItem ));
|
||||||
this.model.updateCheckbox( nodeWidget.item, nodeWidget._checkbox.checked );
|
}
|
||||||
// Generate some additional events
|
}, this );
|
||||||
//this.onClick( nodeWidget.item, nodeWidget, e );
|
|
||||||
if(nodeWidget._checkbox.checked) {
|
|
||||||
this.onNodeChecked( nodeWidget.item, nodeWidget);
|
|
||||||
} else {
|
|
||||||
this.onNodeUnchecked( nodeWidget.item, nodeWidget);
|
|
||||||
}
|
|
||||||
this.focusNode(nodeWidget);
|
|
||||||
},
|
|
||||||
|
|
||||||
_onCheckboxChange: function(/*dojo.data.Item*/ storeItem ) {
|
|
||||||
// summary:
|
|
||||||
// Processes notification of a change to a checkbox state (triggered by the model).
|
|
||||||
// description:
|
|
||||||
// Whenever the model changes the state of a checkbox in the dojo.data.store it will
|
|
||||||
// trigger the 'onCheckboxChange' event allowing the Tree to make the same changes
|
|
||||||
// on the tree Node. There are several conditions why a tree node or checkbox does not
|
|
||||||
// exists:
|
|
||||||
// a) The node has not been created yet (the user has not expanded the tree node yet).
|
|
||||||
// b) The checkbox may be null if condition (a) exists or no 'checkbox' attribute was
|
|
||||||
// specified for the associated dojo.data.item and the attribute 'checkboxAll' is
|
|
||||||
// set to false.
|
|
||||||
// tags:
|
|
||||||
// callback
|
|
||||||
var model = this.model,
|
|
||||||
identity = model.getIdentity(storeItem),
|
|
||||||
nodes = this._itemNodesMap[identity];
|
|
||||||
|
|
||||||
// As of dijit.Tree 1.4 multiple references (parents) are supported, therefore we may have
|
|
||||||
// to update multiple nodes which are all associated with the same dojo.data.item.
|
|
||||||
if( nodes ) {
|
|
||||||
dojo.forEach( nodes, function(node) {
|
|
||||||
if( node._checkbox != null ) {
|
|
||||||
node._checkbox.attr('checked', this.model.getCheckboxState( storeItem ));
|
|
||||||
}
|
}
|
||||||
}, this );
|
},
|
||||||
}
|
|
||||||
},
|
postCreate: function() {
|
||||||
|
// summary:
|
||||||
postCreate: function() {
|
// Handle any specifics related to the tree and model after the instanciation of the Tree.
|
||||||
// summary:
|
// description:
|
||||||
// Handle any specifics related to the tree and model after the instanciation of the Tree.
|
// Validate if we have a 'write' store first. Subscribe to the 'onCheckboxChange' event
|
||||||
// description:
|
// (triggered by the model) and kickoff the initial checkbox data validation.
|
||||||
// Validate if we have a 'write' store first. Subscribe to the 'onCheckboxChange' event
|
//
|
||||||
// (triggered by the model) and kickoff the initial checkbox data validation.
|
var store = this.model.store;
|
||||||
//
|
if(!store.getFeatures()['dojo.data.api.Write']){
|
||||||
var store = this.model.store;
|
throw new Error("lib.CheckboxTree: store must support dojo.data.Write");
|
||||||
if(!store.getFeatures()['dojo.data.api.Write']){
|
}
|
||||||
throw new Error("lib.CheckboxTree: store must support dojo.data.Write");
|
this.connect(this.model, "onCheckboxChange", "_onCheckboxChange");
|
||||||
}
|
this.model.validateData( this.model.root, this.model );
|
||||||
this.connect(this.model, "onCheckboxChange", "_onCheckboxChange");
|
this.inherited(arguments);
|
||||||
this.model.validateData( this.model.root, this.model );
|
},
|
||||||
this.inherited(arguments);
|
|
||||||
},
|
_createTreeNode: function( args ) {
|
||||||
|
// summary:
|
||||||
_createTreeNode: function( args ) {
|
// Create a new CheckboxTreeNode instance.
|
||||||
// summary:
|
// description:
|
||||||
// Create a new CheckboxTreeNode instance.
|
// Create a new CheckboxTreeNode instance.
|
||||||
// description:
|
return new lib._CheckBoxTreeNode(args);
|
||||||
// Create a new CheckboxTreeNode instance.
|
}
|
||||||
return new lib._CheckBoxTreeNode(args);
|
|
||||||
}
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,40 +1,41 @@
|
|||||||
dojo.addOnLoad(function() {
|
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
|
||||||
PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) {
|
ready(function () {
|
||||||
if (row) {
|
PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function (row) {
|
||||||
console.log("af_zz_noautoplay!");
|
if (row) {
|
||||||
console.log(row);
|
console.log("af_zz_noautoplay!");
|
||||||
|
console.log(row);
|
||||||
var videos = row.getElementsByTagName("video");
|
|
||||||
console.log(row.innerHTML);
|
var videos = row.getElementsByTagName("video");
|
||||||
|
console.log(row.innerHTML);
|
||||||
for (i = 0; i < videos.length; i++) {
|
|
||||||
|
for (i = 0; i < videos.length; i++) {
|
||||||
videos[i].removeAttribute("autoplay");
|
|
||||||
videos[i].pause();
|
videos[i].removeAttribute("autoplay");
|
||||||
videos[i].onclick = function() {
|
videos[i].pause();
|
||||||
this.paused ? this.play() : this.pause();
|
videos[i].onclick = function () {
|
||||||
|
this.paused ? this.play() : this.pause();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED, function(row) {
|
PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED, function (row) {
|
||||||
if (row) {
|
if (row) {
|
||||||
var videos = row.getElementsByTagName("video");
|
var videos = row.getElementsByTagName("video");
|
||||||
|
|
||||||
for (i = 0; i < videos.length; i++) {
|
for (i = 0; i < videos.length; i++) {
|
||||||
videos[i].removeAttribute("autoplay");
|
videos[i].removeAttribute("autoplay");
|
||||||
videos[i].pause();
|
videos[i].pause();
|
||||||
videos[i].onclick = function() {
|
videos[i].onclick = function () {
|
||||||
this.paused ? this.play() : this.pause();
|
this.paused ? this.play() : this.pause();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
@ -1,5 +1,7 @@
|
|||||||
dojo.addOnLoad(function() {
|
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
|
||||||
updateTitle = function() {
|
ready(function () {
|
||||||
document.title = "Tiny Tiny RSS";
|
updateTitle = function () {
|
||||||
};
|
document.title = "Tiny Tiny RSS";
|
||||||
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
dojo.addOnLoad(function() {
|
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
|
||||||
hash_set = function() { };
|
ready(function () {
|
||||||
hash_get = function() { };
|
hash_set = function () {
|
||||||
|
};
|
||||||
|
hash_get = function () {
|
||||||
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue