Class TJSStyleManager
Index
Constructors
Accessors
Methods
Constructors
constructor
- new TJSStyleManager(
opts?: {
document?: Document;
force?: boolean;
id: string;
layerName?: string;
rules?: { [key: string]: string };
version?: number;
},
): TJSStyleManager Parameters
Optional
opts: {
document?: Document;
force?: boolean;
id: string;
layerName?: string;
rules?: { [key: string]: string };
version?: number;
}Options.
Optional
document?: DocumentTarget document to load styles into.
Optional
force?: booleanWhen true, removes any existing matching style sheet and initializes a new one.
id: string
Required CSS ID providing a link to a specific style sheet element.
Optional
layerName?: stringOptional CSS layer name defining the top level CSS rule.
Optional
rules?: { [key: string]: string }Optional CSS Rules configuration.
Optional
version?: numberAn integer representing the version / level of styles being managed.
Returns TJSStyleManager
Accessors
isConnected
- get isConnected(): boolean
Determines if this TJSStyleManager is still connected / available.
Returns boolean
Is TJSStyleManager connected.
textContent
- get textContent(): string
Returns string
Provides an accessor to get the
textContent
for the style sheet.
version
- get version(): number
Returns number
Returns the version of this instance.
Methods
clone
- clone(__namedParameters?: Document): TJSStyleManager
Provides a copy constructor to duplicate an existing TJSStyleManager instance into a new document.
Note: This is used to support the
PopOut
module.Parameters
Optional
__namedParameters: Document
Returns TJSStyleManager
New style manager instance or undefined if not connected.
entries
- entries(): MapIterator<[string, CSSRuleManager]>
Returns MapIterator<[string, CSSRuleManager]>
CSSRuleManager entries.
get
- get(ruleName: string): CSSRuleManager
Retrieves an associated CSSRuleManager by name.
Parameters
- ruleName: string
Rule name.
Returns CSSRuleManager
Associated rule manager for given name or undefined if the rule name is not defined or manager is unconnected.
- ruleName: string
has
keys
- keys(): MapIterator<string>
Returns MapIterator<string>
CSSRuleManager keys.
values
- values(): MapIterator<CSSRuleManager>
Returns MapIterator<CSSRuleManager>
Provides a managed dynamic style sheet / element useful in configuring global CSS variables. When creating an instance of TJSStyleManager, you must provide a CSS ID for the style element added.
Instances of TJSStyleManager can also be versioned by supplying a positive number greater than or equal to
1
via the 'version' option. This version number is assigned to the associated style element. When a TJSStyleManager instance is created and there is an existing instance with a version that is lower than the current new instance, all CSS rules are removed, letting the higher version take precedence. This isn't a perfect system and requires thoughtful construction of CSS variables exposed, but allows multiple independently compiled TRL packages to load the latest CSS variables. It is recommended to always setoverwrite
option of TJSStyleManager.setProperty and TJSStyleManager.setProperties tofalse
when loading initial values.