]> git.wh0rd.org - tt-rss.git/blob - js/PrefLabelTree.js
pngcrush.sh
[tt-rss.git] / js / PrefLabelTree.js
1 /* global lib,dijit */
2 define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) {
3
4 return declare("fox.PrefLabelTree", lib.CheckBoxTree, {
5 setNameById: function (id, name) {
6 const item = this.model.store._itemsByIdentity['LABEL:' + id];
7
8 if (item)
9 this.model.store.setValue(item, 'name', name);
10
11 },
12 _createTreeNode: function(args) {
13 const tnode = this.inherited(arguments);
14
15 const fg_color = this.model.store.getValue(args.item, 'fg_color');
16 const bg_color = this.model.store.getValue(args.item, 'bg_color');
17 const type = this.model.store.getValue(args.item, 'type');
18 const bare_id = this.model.store.getValue(args.item, 'bare_id');
19
20 if (type == 'label') {
21 const span = dojo.doc.createElement('span');
22 span.innerHTML = 'α';
23 span.className = 'labelColorIndicator';
24 span.id = 'LICID-' + bare_id;
25
26 span.setStyle({
27 color: fg_color,
28 backgroundColor: bg_color});
29
30 tnode._labelIconNode = span;
31
32 domConstruct.place(tnode._labelIconNode, tnode.labelNode, 'before');
33 }
34
35 return tnode;
36 },
37 getIconClass: function (item, opened) {
38 return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible";
39 },
40 });
41
42 });
43
44