-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathicon.js
64 lines (55 loc) · 2 KB
/
icon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"use strict";
/**
* Immutable hash of icon data.
*
* These objects are accessed through {@link IconDelegate} instances, and
* generated at startup from precomposed data by the {@link IconCompiler}.
*
* @class
*/
class Icon{
/**
* Create a new icon object.
*
* @param {Number} index - Index of the icon's appearance in the enclosing array
* @param {String} icon - Icon's CSS class (e.g., "js-icon")
* @param {Array} colour - Icon's colour classes
* @param {RegExp} match - Pattern for matching names or pathnames
* @param {Number} [priority=1] - Numeric priority that determined icon's order of appearance
* @param {Boolean} [matchPath=false] - Match against system path instead of basename
* @param {RegExp} [interpreter=null] - RegExp to match executable names in hashbangs
* @param {RegExp} [scope=null] - RegExp to match grammar scope-names
* @param {RegExp} [lang=null] - RegExp to match alias patterns
* @param {RegExp} [sig=null] - RegExp to match file signatures
* @see {@link IconTables#read}
* @constructor
*/
constructor(index, icon, colour, match, priority = 1, matchPath = null, interpreter = null, scope = null, lang = null, sig = null){
this.index = index;
this.icon = icon;
this.colour = colour;
this.match = match;
this.priority = priority;
this.matchPath = matchPath || false;
this.interpreter = interpreter || null;
this.scope = scope || null;
this.lang = lang || null;
this.signature = sig || null;
}
/**
* Return the CSS classes for displaying the icon.
*
* @param {Number|null} colourMode
* @param {Boolean} asArray
* @return {String}
*/
getClass(colourMode = null, asArray = false){
// No colour needed or available
if(null === colourMode || null === this.colour[0])
return asArray ? [this.icon] : this.icon;
return asArray
? [this.icon, this.colour[colourMode]]
: (this.icon + " " + this.colour[colourMode]);
}
}
module.exports = Icon;