DynamicStyle.js
This javascript "library" (more of a helper) implements an on-the-fly global style manager. Scripts can add, modify, retrieve, and remove snippets of CSS that are applied globally, with very little overhead. Example calls:
DynamicStyle.setStyle('search-hilite', 'span.search-1 { background-color: yellow; }');
DynamicStyle.getStyle('search-hilite');
DynamicStyle.removeStyle('search-hilite');
Download the current version (0.5). (Depends on JQuery, but only for initialization.)
Specification
DynamicStyle.js exposes three public API calls:
- DynamicStyle.setStyle(handle, snippet)
- Add or update the dynamic stylesheet with the handle "handle".
- DynamicStyle.getStyle(handle)
- Retrieve the contents of the dynamic stylesheet with the handle "handle".
- DynamicStyle.removeStyle(handle)
- Destroy the dynamic stylesheet with the handle "handle".
The library uses data: URLs to simulate external stylesheets.
Future work
None currently planned.
Change log
Version 0.5
Released on 2007-1-21, version 0.5 [.js format] changes dependency from Prototype.js to JQuery.js.
Version 0.4
Released on 2006-9-27, version 0.4 [.js format] is the first public version. Provides the following API calls:
- DynamicStyle.setStyle(handle, snippet)
- Add or update the dynamic stylesheet with the handle "handle".
- DynamicStyle.getStyle(handle)
- Retrieve the contents of the dynamic stylesheet with the handle "handle".
- DynamicStyle.removeStyle(handle)
- Destroy the dynamic stylesheet with the handle "handle".
The library uses data: URLs to simulate external stylesheets.
Requires the Prototype.js library.