move to let/const syntax in custom dojo modules

master
Andrew Dolgov 6 years ago
parent 9dc5524df1
commit 0267212454

@ -4,7 +4,7 @@ define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare)
getItemsInCategory: function (id) { getItemsInCategory: function (id) {
if (!this.store._itemsByIdentity) return undefined; if (!this.store._itemsByIdentity) return undefined;
cat = this.store._itemsByIdentity['CAT:' + id]; let cat = this.store._itemsByIdentity['CAT:' + id];
if (cat && cat.items) if (cat && cat.items)
return cat.items; return cat.items;
@ -30,7 +30,7 @@ define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare)
return this.getFeedValue(feed, is_cat, 'name'); return this.getFeedValue(feed, is_cat, 'name');
}, },
getFeedUnread: function (feed, is_cat) { getFeedUnread: function (feed, is_cat) {
var unread = parseInt(this.getFeedValue(feed, is_cat, 'unread')); const unread = parseInt(this.getFeedValue(feed, is_cat, 'unread'));
return (isNaN(unread)) ? 0 : unread; return (isNaN(unread)) ? 0 : unread;
}, },
setFeedUnread: function (feed, is_cat, unread) { setFeedUnread: function (feed, is_cat, unread) {
@ -58,14 +58,14 @@ define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare)
treeItem = this.store._itemsByIdentity['FEED:' + feed]; treeItem = this.store._itemsByIdentity['FEED:' + feed];
} }
items = this.store._arrayOfAllItems; let items = this.store._arrayOfAllItems;
for (var i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
if (items[i] == treeItem) { if (items[i] == treeItem) {
for (var j = i + 1; j < items.length; j++) { for (var j = i + 1; j < items.length; j++) {
var unread = this.store.getValue(items[j], 'unread'); let unread = this.store.getValue(items[j], 'unread');
var id = this.store.getValue(items[j], 'id'); let id = this.store.getValue(items[j], 'id');
if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) { if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) {
if (!is_cat || !(this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed)) return items[j]; if (!is_cat || !(this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed)) return items[j];
@ -73,8 +73,8 @@ define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare)
} }
for (var j = 0; j < i; j++) { for (var j = 0; j < i; j++) {
var unread = this.store.getValue(items[j], 'unread'); let unread = this.store.getValue(items[j], 'unread');
var id = this.store.getValue(items[j], 'id'); let id = this.store.getValue(items[j], 'id');
if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) { if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) {
if (!is_cat || !(this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed)) return items[j]; if (!is_cat || !(this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed)) return items[j];

@ -1,3 +1,4 @@
/* global dijit */
define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct) {
return declare("fox.FeedTree", dijit.Tree, { return declare("fox.FeedTree", dijit.Tree, {
@ -5,9 +6,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
return; // Stop dijit.Tree from interpreting keystrokes return; // Stop dijit.Tree from interpreting keystrokes
}, },
_createTreeNode: function(args) { _createTreeNode: function(args) {
var tnode = new dijit._TreeNode(args); const tnode = new dijit._TreeNode(args);
var icon = dojo.doc.createElement('img'); const icon = dojo.doc.createElement('img');
if (args.item.icon && args.item.icon[0]) { if (args.item.icon && args.item.icon[0]) {
icon.src = args.item.icon[0]; icon.src = args.item.icon[0];
} else { } else {
@ -16,13 +17,13 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
icon.className = 'tinyFeedIcon'; icon.className = 'tinyFeedIcon';
domConstruct.place(icon, tnode.iconNode, 'only'); domConstruct.place(icon, tnode.iconNode, 'only');
var id = args.item.id[0]; const id = args.item.id[0];
var bare_id = parseInt(id.substr(id.indexOf(':')+1)); const bare_id = parseInt(id.substr(id.indexOf(':')+1));
if (bare_id < _label_base_index) { if (bare_id < _label_base_index) {
var span = dojo.doc.createElement('span'); const span = dojo.doc.createElement('span');
var fg_color = args.item.fg_color[0]; const fg_color = args.item.fg_color[0];
var bg_color = args.item.bg_color[0]; const bg_color = args.item.bg_color[0];
span.innerHTML = "&alpha;"; span.innerHTML = "&alpha;";
span.className = 'labelColorIndicator'; span.className = 'labelColorIndicator';
@ -34,7 +35,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
} }
if (id.match("FEED:")) { if (id.match("FEED:")) {
var menu = new dijit.Menu(); let menu = new dijit.Menu();
menu.row_id = bare_id; menu.row_id = bare_id;
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
@ -62,7 +63,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
} }
if (id.match("CAT:") && bare_id >= 0) { if (id.match("CAT:") && bare_id >= 0) {
var menu = new dijit.Menu(); let menu = new dijit.Menu();
menu.row_id = bare_id; menu.row_id = bare_id;
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
@ -90,7 +91,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
} }
if (id.match("CAT:") && bare_id == -1) { if (id.match("CAT:") && bare_id == -1) {
var menu = new dijit.Menu(); let menu = new dijit.Menu();
menu.row_id = bare_id; menu.row_id = bare_id;
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
@ -128,11 +129,11 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
this.inherited(arguments); this.inherited(arguments);
}, },
updateCounter: function (item) { updateCounter: function (item) {
var tree = this; const tree = this;
//console.log("updateCounter: " + item.id[0] + " " + item.unread + " " + tree); //console.log("updateCounter: " + item.id[0] + " " + item.unread + " " + tree);
var node = tree._itemNodesMap[item.id]; let node = tree._itemNodesMap[item.id];
if (node) { if (node) {
node = node[0]; node = node[0];
@ -166,7 +167,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
return (item.unread == 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread"; return (item.unread == 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread";
}, },
getRowClass: function (item, opened) { getRowClass: function (item, opened) {
var rc = (!item.error || item.error == '') ? "dijitTreeRow" : let rc = (!item.error || item.error == '') ? "dijitTreeRow" :
"dijitTreeRow Error"; "dijitTreeRow Error";
if (item.unread > 0) rc += " Unread"; if (item.unread > 0) rc += " Unread";
@ -175,7 +176,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
return rc; return rc;
}, },
getLabel: function(item) { getLabel: function(item) {
var name = String(item.name); let name = String(item.name);
/* Horrible */ /* Horrible */
name = name.replace(/&quot;/g, "\""); name = name.replace(/&quot;/g, "\"");
@ -196,9 +197,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
}, },
expandParentNodes: function(feed, is_cat, list) { expandParentNodes: function(feed, is_cat, list) {
try { try {
for (var i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
var id = String(list[i].id); const id = String(list[i].id);
var item = this._itemNodesMap[id]; let item = this._itemNodesMap[id];
if (item) { if (item) {
item = item[0]; item = item[0];
@ -213,37 +214,33 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
// expands all parents of specified feed to properly mark it as active // expands all parents of specified feed to properly mark it as active
// my fav thing about frameworks is doing everything myself // my fav thing about frameworks is doing everything myself
try { try {
var test_id = is_cat ? 'CAT:' + feed : 'FEED:' + feed; const test_id = is_cat ? 'CAT:' + feed : 'FEED:' + feed;
if (!root) { if (!root) {
if (!this.model || !this.model.store) return false; if (!this.model || !this.model.store) return false;
var items = this.model.store._arrayOfTopLevelItems; const items = this.model.store._arrayOfTopLevelItems;
for (var i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
if (String(items[i].id) == test_id) { if (String(items[i].id) == test_id) {
this.expandParentNodes(feed, is_cat, parents); this.expandParentNodes(feed, is_cat, parents);
} else { } else {
this.findNodeParentsAndExpandThem(feed, is_cat, items[i], []); this.findNodeParentsAndExpandThem(feed, is_cat, items[i], []);
} }
} }
} else { } else if (root.items) {
if (root.items) {
parents.push(root); parents.push(root);
for (var i = 0; i < root.items.length; i++) { for (let i = 0; i < root.items.length; i++) {
if (String(root.items[i].id) == test_id) { if (String(root.items[i].id) == test_id) {
this.expandParentNodes(feed, is_cat, parents); this.expandParentNodes(feed, is_cat, parents);
} else { } else {
this.findNodeParentsAndExpandThem(feed, is_cat, root.items[i], parents.slice(0)); this.findNodeParentsAndExpandThem(feed, is_cat, root.items[i], parents.slice(0));
} }
} }
} else { } else if (String(root.id) == test_id) {
if (String(root.id) == test_id) {
this.expandParentNodes(feed, is_cat, parents.slice(0)); this.expandParentNodes(feed, is_cat, parents.slice(0));
} }
}
}
} catch (e) { } catch (e) {
exception_error(e); exception_error(e);
} }
@ -276,7 +273,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
if (treeNode) { if (treeNode) {
treeNode = treeNode[0]; treeNode = treeNode[0];
var icon = dojo.doc.createElement('img'); const icon = dojo.doc.createElement('img');
icon.src = src; icon.src = src;
icon.className = 'tinyFeedIcon'; icon.className = 'tinyFeedIcon';
domConstruct.place(icon, treeNode.iconNode, 'only'); domConstruct.place(icon, treeNode.iconNode, 'only');
@ -296,7 +293,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
treeNode.loadingNode.src = src; treeNode.loadingNode.src = src;
return true; return true;
} else { } else {
var icon = dojo.doc.createElement('img'); const icon = dojo.doc.createElement('img');
icon.src = src; icon.src = src;
icon.className = 'loadingExpando'; icon.className = 'loadingExpando';
domConstruct.place(icon, treeNode.expandoNode, 'only'); domConstruct.place(icon, treeNode.expandoNode, 'only');
@ -311,17 +308,17 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
}, },
hideReadCat: function (cat, hide, show_special) { hideReadCat: function (cat, hide, show_special) {
if (this.hasCats()) { if (this.hasCats()) {
var tree = this; const tree = this;
if (cat && cat.items) { if (cat && cat.items) {
var cat_unread = tree.hideReadFeeds(cat.items, hide, show_special); let cat_unread = tree.hideReadFeeds(cat.items, hide, show_special);
var id = String(cat.id); const id = String(cat.id);
var node = tree._itemNodesMap[id]; const node = tree._itemNodesMap[id];
var bare_id = parseInt(id.substr(id.indexOf(":")+1)); const bare_id = parseInt(id.substr(id.indexOf(":")+1));
if (node) { if (node) {
var check_unread = tree.model.getFeedUnread(bare_id, true); const check_unread = tree.model.getFeedUnread(bare_id, true);
if (hide && cat_unread == 0 && check_unread == 0 && (id != "CAT:-1" || !show_special)) { if (hide && cat_unread == 0 && check_unread == 0 && (id != "CAT:-1" || !show_special)) {
Effect.Fade(node[0].rowNode, {duration : 0.3, Effect.Fade(node[0].rowNode, {duration : 0.3,
@ -337,8 +334,8 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
hideRead: function (hide, show_special) { hideRead: function (hide, show_special) {
if (this.hasCats()) { if (this.hasCats()) {
var tree = this; const tree = this;
var cats = this.model.store._arrayOfTopLevelItems; const cats = this.model.store._arrayOfTopLevelItems;
cats.each(function(cat) { cats.each(function(cat) {
tree.hideReadCat(cat, hide, show_special); tree.hideReadCat(cat, hide, show_special);
@ -350,21 +347,21 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
} }
}, },
hideReadFeeds: function (items, hide, show_special) { hideReadFeeds: function (items, hide, show_special) {
var tree = this; const tree = this;
var cat_unread = 0; let cat_unread = 0;
items.each(function(feed) { items.each(function(feed) {
var id = String(feed.id); const id = String(feed.id);
// it's a subcategory // it's a subcategory
if (feed.items) { if (feed.items) {
tree.hideReadCat(feed, hide, show_special); tree.hideReadCat(feed, hide, show_special);
} else { // it's a feed } else { // it's a feed
var bare_id = parseInt(feed.bare_id);; const bare_id = parseInt(feed.bare_id);
var unread = feed.unread[0]; const unread = feed.unread[0];
var has_error = feed.error[0] != ''; const has_error = feed.error[0] != '';
var node = tree._itemNodesMap[id]; const node = tree._itemNodesMap[id];
if (node) { if (node) {
if (hide && unread == 0 && !has_error && (bare_id > 0 || bare_id < _label_base_index || !show_special)) { if (hide && unread == 0 && !has_error && (bare_id > 0 || bare_id < _label_base_index || !show_special)) {
@ -383,10 +380,10 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
collapseCat: function(id) { collapseCat: function(id) {
if (!this.model.hasCats()) return; if (!this.model.hasCats()) return;
var tree = this; const tree = this;
var node = tree._itemNodesMap['CAT:' + id][0]; const node = tree._itemNodesMap['CAT:' + id][0];
var item = tree.model.store._itemsByIdentity['CAT:' + id]; const item = tree.model.store._itemsByIdentity['CAT:' + id];
if (node && item) { if (node && item) {
if (!node.isExpanded) if (!node.isExpanded)
@ -397,16 +394,16 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
} }
}, },
getVisibleUnreadFeeds: function() { getVisibleUnreadFeeds: function() {
var items = this.model.store._arrayOfAllItems; const items = this.model.store._arrayOfAllItems;
var rv = []; const rv = [];
for (var i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
var id = String(items[i].id); const id = String(items[i].id);
var box = this._itemNodesMap[id]; const box = this._itemNodesMap[id];
if (box) { if (box) {
var row = box[0].rowNode; const row = box[0].rowNode;
var cat = false; let cat = false;
try { try {
cat = box[0].rowNode.parentNode.parentNode; cat = box[0].rowNode.parentNode.parentNode;
@ -414,9 +411,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
if (row) { if (row) {
if (Element.visible(row) && (!cat || Element.visible(cat))) { if (Element.visible(row) && (!cat || Element.visible(cat))) {
var feed_id = String(items[i].bare_id); const feed_id = String(items[i].bare_id);
var is_cat = !id.match('FEED:'); const is_cat = !id.match('FEED:');
var unread = this.model.getFeedUnread(feed_id, is_cat); const unread = this.model.getFeedUnread(feed_id, is_cat);
if (unread > 0) if (unread > 0)
rv.push([feed_id, is_cat]); rv.push([feed_id, is_cat]);
@ -435,19 +432,19 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
treeItem = this.model.store._itemsByIdentity['FEED:' + feed]; treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
} }
items = this.model.store._arrayOfAllItems; const items = this.model.store._arrayOfAllItems;
var item = items[0]; let item = items[0];
for (var i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
if (items[i] == treeItem) { if (items[i] == treeItem) {
for (var j = i+1; j < items.length; j++) { for (let j = i+1; j < items.length; j++) {
var id = String(items[j].id); const id = String(items[j].id);
var box = this._itemNodesMap[id]; const box = this._itemNodesMap[id];
if (box) { if (box) {
var row = box[0].rowNode; const row = box[0].rowNode;
var cat = box[0].rowNode.parentNode.parentNode; const cat = box[0].rowNode.parentNode.parentNode;
if (Element.visible(cat) && Element.visible(row)) { if (Element.visible(cat) && Element.visible(row)) {
item = items[j]; item = items[j];
@ -473,19 +470,19 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
treeItem = this.model.store._itemsByIdentity['FEED:' + feed]; treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
} }
items = this.model.store._arrayOfAllItems; const items = this.model.store._arrayOfAllItems;
var item = items[0] == treeItem ? items[items.length-1] : items[0]; let item = items[0] == treeItem ? items[items.length-1] : items[0];
for (var i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
if (items[i] == treeItem) { if (items[i] == treeItem) {
for (var j = i-1; j > 0; j--) { for (let j = i-1; j > 0; j--) {
var id = String(items[j].id); const id = String(items[j].id);
var box = this._itemNodesMap[id]; const box = this._itemNodesMap[id];
if (box) { if (box) {
var row = box[0].rowNode; const row = box[0].rowNode;
var cat = box[0].rowNode.parentNode.parentNode; const cat = box[0].rowNode.parentNode.parentNode;
if (Element.visible(cat) && Element.visible(row)) { if (Element.visible(cat) && Element.visible(row)) {
item = items[j]; item = items[j];

@ -1,6 +1,6 @@
// based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system // based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system
var PluginHost = { const PluginHost = {
HOOK_ARTICLE_RENDERED: 1, HOOK_ARTICLE_RENDERED: 1,
HOOK_ARTICLE_RENDERED_CDM: 2, HOOK_ARTICLE_RENDERED_CDM: 2,
HOOK_ARTICLE_SET_ACTIVE: 3, HOOK_ARTICLE_SET_ACTIVE: 3,

@ -1,10 +1,11 @@
/* global lib,dijit */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) {
return declare("fox.PrefFeedTree", lib.CheckBoxTree, { return declare("fox.PrefFeedTree", lib.CheckBoxTree, {
_createTreeNode: function(args) { _createTreeNode: function(args) {
var tnode = this.inherited(arguments); const tnode = this.inherited(arguments);
var icon = dojo.doc.createElement('img'); const icon = dojo.doc.createElement('img');
if (args.item.icon && args.item.icon[0]) { if (args.item.icon && args.item.icon[0]) {
icon.src = args.item.icon[0]; icon.src = args.item.icon[0];
} else { } else {
@ -13,7 +14,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
icon.className = 'tinyFeedIcon'; icon.className = 'tinyFeedIcon';
domConstruct.place(icon, tnode.iconNode, 'only'); domConstruct.place(icon, tnode.iconNode, 'only');
var param = this.model.store.getValue(args.item, 'param'); let param = this.model.store.getValue(args.item, 'param');
if (param) { if (param) {
param = dojo.doc.createElement('span'); param = dojo.doc.createElement('span');
@ -23,8 +24,8 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
domConstruct.place(param, tnode.rowNode, 'first'); domConstruct.place(param, tnode.rowNode, 'first');
} }
var id = args.item.id[0]; const id = args.item.id[0];
var bare_id = parseInt(id.substr(id.indexOf(':')+1)); const bare_id = parseInt(id.substr(id.indexOf(':')+1));
if (id.match("CAT:") && bare_id > 0) { if (id.match("CAT:") && bare_id > 0) {
var menu = new dijit.Menu(); var menu = new dijit.Menu();
@ -82,12 +83,12 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
return (!item || this.model.store.getValue(item, 'type') == 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon"; return (!item || this.model.store.getValue(item, 'type') == 'category') ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
}, },
checkItemAcceptance: function(target, source, position) { checkItemAcceptance: function(target, source, position) {
var item = dijit.getEnclosingWidget(target).item; const item = dijit.getEnclosingWidget(target).item;
// disable copying items // disable copying items
source.copyState = function() { return false; }; source.copyState = function() { return false; };
var source_item = false; let source_item = false;
source.forInSelectedItems(function(node) { source.forInSelectedItems(function(node) {
source_item = node.data.item; source_item = node.data.item;
@ -95,8 +96,8 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
if (!source_item || !item) return false; if (!source_item || !item) return false;
var id = this.tree.model.store.getValue(item, 'id'); const id = this.tree.model.store.getValue(item, 'id');
var source_id = source.tree.model.store.getValue(source_item, 'id'); const source_id = source.tree.model.store.getValue(source_item, 'id');
//console.log(id + " " + position + " " + source_id); //console.log(id + " " + position + " " + source_id);

@ -1,12 +1,13 @@
/* global dijit,lib */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) {
return declare("fox.PrefFilterTree", lib.CheckBoxTree, { return declare("fox.PrefFilterTree", lib.CheckBoxTree, {
_createTreeNode: function(args) { _createTreeNode: function(args) {
var tnode = this.inherited(arguments); const tnode = this.inherited(arguments);
var enabled = this.model.store.getValue(args.item, 'enabled'); const enabled = this.model.store.getValue(args.item, 'enabled');
var param = this.model.store.getValue(args.item, 'param'); let param = this.model.store.getValue(args.item, 'param');
var rules = this.model.store.getValue(args.item, 'rules'); const rules = this.model.store.getValue(args.item, 'rules');
if (param) { if (param) {
param = dojo.doc.createElement('span'); param = dojo.doc.createElement('span');
@ -23,7 +24,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
} }
if (this.model.store.getValue(args.item, 'id') != 'root') { if (this.model.store.getValue(args.item, 'id') != 'root') {
var img = dojo.doc.createElement('img'); const img = dojo.doc.createElement('img');
img.src ='images/filter.png'; img.src ='images/filter.png';
img.className = 'markedPic'; img.className = 'markedPic';
tnode._filterIconNode = img; tnode._filterIconNode = img;
@ -34,10 +35,10 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
}, },
getLabel: function(item) { getLabel: function(item) {
var label = item.name; let label = item.name;
var feed = this.model.store.getValue(item, 'feed'); const feed = this.model.store.getValue(item, 'feed');
var inverse = this.model.store.getValue(item, 'inverse'); const inverse = this.model.store.getValue(item, 'inverse');
if (feed) if (feed)
label += " (" + __("in") + " " + feed + ")"; label += " (" + __("in") + " " + feed + ")";
@ -55,7 +56,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible"; return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible";
}, },
getLabelClass: function (item, opened) { getLabelClass: function (item, opened) {
var enabled = this.model.store.getValue(item, 'enabled'); const enabled = this.model.store.getValue(item, 'enabled');
return (enabled != false) ? "dijitTreeLabel labelFixedLength" : "dijitTreeLabel labelFixedLength filterDisabled"; return (enabled != false) ? "dijitTreeLabel labelFixedLength" : "dijitTreeLabel labelFixedLength filterDisabled";
}, },
getRowClass: function (item, opened) { getRowClass: function (item, opened) {
@ -63,7 +64,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
"dijitTreeRow Error"; "dijitTreeRow Error";
}, },
checkItemAcceptance: function(target, source, position) { checkItemAcceptance: function(target, source, position) {
var item = dijit.getEnclosingWidget(target).item; const item = dijit.getEnclosingWidget(target).item;
// disable copying items // disable copying items
source.copyState = function() { return false; }; source.copyState = function() { return false; };

@ -1,23 +1,24 @@
/* global lib,dijit */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) {
return declare("fox.PrefLabelTree", lib.CheckBoxTree, { return declare("fox.PrefLabelTree", lib.CheckBoxTree, {
setNameById: function (id, name) { setNameById: function (id, name) {
var item = this.model.store._itemsByIdentity['LABEL:' + id]; const item = this.model.store._itemsByIdentity['LABEL:' + id];
if (item) if (item)
this.model.store.setValue(item, 'name', name); this.model.store.setValue(item, 'name', name);
}, },
_createTreeNode: function(args) { _createTreeNode: function(args) {
var tnode = this.inherited(arguments); const tnode = this.inherited(arguments);
var fg_color = this.model.store.getValue(args.item, 'fg_color'); const fg_color = this.model.store.getValue(args.item, 'fg_color');
var bg_color = this.model.store.getValue(args.item, 'bg_color'); const bg_color = this.model.store.getValue(args.item, 'bg_color');
var type = this.model.store.getValue(args.item, 'type'); const type = this.model.store.getValue(args.item, 'type');
var bare_id = this.model.store.getValue(args.item, 'bare_id'); const bare_id = this.model.store.getValue(args.item, 'bare_id');
if (type == 'label') { if (type == 'label') {
var span = dojo.doc.createElement('span'); const span = dojo.doc.createElement('span');
span.innerHTML = '&alpha;'; span.innerHTML = '&alpha;';
span.className = 'labelColorIndicator'; span.className = 'labelColorIndicator';
span.id = 'LICID-' + bare_id; span.id = 'LICID-' + bare_id;

Loading…
Cancel
Save