yoja-web
JavaScript / CSS / HTML framework for modular web apps. Section-based
components, routing, i18n, HTTP, WebSocket, storage — all in native ES6
modules. No build toolchain, no node_modules, no virtual DOM.
Why yoja-web
- Zero build toolchain. Drop a JS file, reload the page.
- Native ES6 modules — no magic. Standard
import, served as-is. - Built-in cache busting — no content hashing. A
versiondeclared inYojaWeb.conf.jsis appended as?version=…to every imported module, CSS and resource URL. Bump it and browsers re-fetch instead of serving stale files. The config file itself is always loaded uncached (?date=<timestamp>), so a new version takes effect on the very next page load. - Native Shadow DOM for CSS scoping (when you want it).
- HTML-first architecture. Components are declared with attributes (
yw-*), hydrated from JS classes. - Gradual adoption. Drop yoja-web into an existing page; nothing else has to change.
- Works well with AI. Plain standard HTML / CSS / ES6 with no hidden build step, no JSX and no virtual DOM — so AI coding assistants read the project as-is and generate code that runs without a transpilation round-trip.
Installation
Yoja-Web ships as a jar packaged at com.easygoingapi.yoja.web.
Mount it as a static resource on a yoja-http-server router
and reference it from your HTML:
HttpRouter.builder()
.webResource(WebApp.of(WebApp.Type.jar,
"com.easygoingapi.yoja.web",
"/yoja"),
"/*")
.webResource(WebApp.jar("my.app.webapp"), "/*")
.build();
<script type="module"
src="/yoja/YojaWeb-1.7.0.js"
yw-config-path="/YojaWeb.conf.js"></script>
📌 Version in the file name. The version embedded in YojaWeb-1.7.0.js tracks the Yoja Framework release — it is bumped in lockstep with the project, so it always matches the framework version you depend on (here 1.7.0). Reference the file name matching your framework version.
Configuration
The config file is declared via the yw-config-path attribute on the <script> tag.
The framework dynamically imports that path as an ES6 module and reads its default export.
If the attribute is absent the framework starts with an empty config.
If the file cannot be loaded a console.warn is emitted and the framework starts with an empty config.
// /YojaWeb.conf.js
export default {
version: '1.0.1',
defaultLanguage: 'fr',
mediaDescriptions: [
{ name: 'mobile', maxWidth: 767 },
{ name: 'tablet', maxWidth: 1023 },
{ name: 'desktop' }
]
};
version— app version surfaced in debug helpers.defaultLanguage— fallback locale when the browser doesn't advertise a supported one.mediaDescriptions— ordered breakpoints fed toresponsiveService.
HTML directives
A tag becomes a section — a managed component boundary — as soon as it carries at least one of yw-controler, yw-language, yw-css or yw-slot. yw-include is separate: it grafts external HTML but does not create a section. Directive paths are resolved relative to the file that declares them.
yw-controler attribute
Attach a JavaScript controller to the element (making it a section). The value is the path to an ES6 module whose default export is a class; its constructor receives the Section handle. (Note the single-l spelling controler.)
<section yw-controler="./sections/header/HeaderControler.js">
<!-- header markup -->
</section>
// HeaderControler.js
export default class HeaderControler {
constructor(section) {
section.controlerReady(() => { /* every controller of the batch constructed: initialize this one */ });
section.pageReady(() => { /* every controlerReady run: talk to the other sections */ });
}
}
yw-language attribute
Declare the XML translation file for the section's i18n (making it a section). Translations are applied to descendants via the yw-i18n* attributes and re-applied on language change. Combinable with the other directives.
<div yw-controler="./AppControler.js" yw-language="./i18n/en.xml"></div>
yw-css attribute
Attach a CSS file scoped to the section via adopted stylesheets (making it a section). An empty value (yw-css with no path) makes the section inherit its parent section's stylesheet instead of loading its own.
<!-- own scoped stylesheet -->
<div yw-css="./card.css"></div>
<!-- inherit the parent section's stylesheet -->
<div yw-controler="./CardControler.js" yw-css></div>
yw-slot attribute
Point at an HTML template file used as the section's slot for content projected from a parent section (making it a section).
<div yw-slot="./slot.html"></div>
yw-include attribute
Graft an external HTML fragment onto the element. This does not create a section; the included file's own yw-* directives are wired up after grafting, relative to its own location.
<!-- outer (default): the host <div> is replaced by the loaded HTML -->
<div yw-include="./sections/taskdetail/taskdetail.html"></div>
<!-- inner: the host <div> is kept, loaded HTML becomes its children -->
<div yw-include="./sidebar.html" yw-include-mode="inner"></div>
yw-include-mode takes outer or inner; any other value — or omitting it — falls back to outer.
yojaWeb: Global API
window.yojaWeb global object
Runtime entry point injected before any controller runs.
Lifecycle| Signature | Returns | Description |
|---|---|---|
onDocumentReady(fn) | off | Registers fn; fires once after the full document bootstrap — given later, told all the same, just after the call |
onTagReady(fn) | off | Registers fn; fires each time tags are added (append, prepend, appendTag, prependTag) and their sections ready: fn(tags), the tags added |
isReady() | boolean | true once the runtime bootstrap is complete |
onError(fn) | off | Registers a global error handler; also told when a listener of any service throws |
| Signature | Returns | Description |
|---|---|---|
firstTag(selector [, fromTag]) | Element | null | First match; searches from fromTag or document |
findTags(selector [, fromTag]) | Element[] | All matches; searches from fromTag or document |
walkTag(consumer [, fromTag]) | void | Depth-first walk of every element |
| Signature | Returns | Description |
|---|---|---|
firstSectionTag(selector [, fromTag]) | Element | null | First match within section boundaries |
findSectionTags(selector [, fromTag]) | Element[] | All matches within section boundaries |
walkSectionTag(consumer [, fromTag]) | void | Depth-first walk within section boundaries |
| Signature | Returns | Description |
|---|---|---|
path(path [, options]) | string | Normalizes path and appends ?version=…; options.force=true also adds &date=… |
version() | string | The yoja-web version, read from the file name (YojaWeb-<version>.js) — not the application's config.version |
append(tag, path) | Promise<HTMLElement[]> | Fetches HTML at path, appends all children to tag (or its shadow root) |
prepend(tag, path) | Promise<HTMLElement[]> | Same as append, but prepended |
| Property | Type | Description |
|---|---|---|
sectionService | SectionService | Low-level section tree-traversal service |
controlerService | ControlerService | Low-level controller tree-traversal service |
config | object | Config object exported by YojaWeb.conf.js |
window.yojaWebApi global object
Aggregator exposing every service as a single namespace.
Services| Property | Description |
|---|---|
httpClient | Promise-based HTTP client with interceptors and offline fallback |
webSocketService | WebSocket lifecycle management |
storageService | localStorage / sessionStorage wrappers with change events |
eventService | Pub/sub event bus |
navigationService | Client-side navigation and history management |
urlParameterService | Read and write URL query parameters |
responsiveService | Viewport breakpoint detection |
languageService | Internationalisation (i18n) |
cssSheetService | Dynamic CSS stylesheet management |
sectionService | Section tree traversal |
controlerService | Controller tree traversal |
Section: Component Lifecycle
Section class (injected, not exported)
Handle injected into every controller constructor. One Section per DOM element carrying a yw-* directive. A resource of a section failing to load — its controller, yw-css, yw-slot, yw-include — or its controller throwing in its constructor: logged, told to yojaWeb.onError, the section built without it, the others with theirs.
| Property | Type | Description |
|---|---|---|
tag | Element | Root DOM element of this section |
shadowTag | ShadowRoot | null | Shadow root of the section element, if any |
| Signature | Returns | Description |
|---|---|---|
firstTag(selector) | Element | null | First match within the section, stops at nested section boundaries |
findTags(selector) | Element[] | All matches within the section |
walkTag(consumer) | void | Depth-first walk within the section |
| Signature | Returns | Description |
|---|---|---|
deepFirstTag(selector) | Element | null | First match across shadow DOM boundaries |
deepFindTags(selector) | Element[] | All matches across shadow DOM boundaries |
deepWalkTag(consumer) | void | Depth-first walk across shadow DOM |
| Signature | Returns | Description |
|---|---|---|
firstSection(predicate) | Section | null | First descendant section matching predicate |
findSections(predicate) | Section[] | All descendant sections matching predicate |
childrenSections(predicate) | Section[] | Direct child sections only |
closestSection(predicate) | Section | null | Nearest ancestor section matching predicate |
parentSection(predicate) | Section | null | Direct parent section, optionally filtered |
parentSections(predicate) | Section[] | All ancestor sections |
rootSection() | Section | Top-most section ancestor |
walkSection(consumer) | void | Depth-first walk of all descendant sections |
| Signature | Returns | Description |
|---|---|---|
firstControler(predicate) | Controler | null | First descendant controller matching predicate |
findControlers(predicate) | Controler[] | All descendant controllers |
childrenControlers(predicate) | Controler[] | Direct child controllers only |
closestControler(predicate) | Controler | null | Nearest ancestor controller |
parentControler(predicate) | Controler | null | Direct parent controller, optionally filtered |
parentControlers(predicate) | Controler[] | All ancestor controllers |
rootControler() | Controler | Top-most controller ancestor |
walkControler(consumer) | void | Depth-first walk of all descendant controllers |
| Signature | Returns | Description |
|---|---|---|
controlerReady(action) | void | Registers action; fires once every section of its batch (the page, or an addition) has its controller constructed — given later, told all the same, just after the call; the section gone, never |
pageReady(action) | void | Registers action; fires once every controlerReady of its batch has run, so the other sections can be talked to — before the translation; given later, told all the same, just after the call; the section gone, never |
Ready order — sections are built by batches: the page at load time, then each append, prepend, appendTag, prependTag. Once a batch is built: every controlerReady, then every pageReady, then yojaWeb.onTagReady(tags) (an addition) or yojaWeb.onDocumentReady (the page); then the batch is translated and shown. Each step is a console.debug line: applyYojaWebOnTags, YojaWeb controlerReady, YojaWeb pageReady, YojaWeb tagReady / YojaWeb documentReady. | ||
track(off) | off | Runs the off of a subscription once the section has left the page (gone already: at once); returns the same off. Not a function: TypeError. See Listeners |
| Signature | Returns | Description |
|---|---|---|
log() | void | Logs the section tree structure to the console |
logCss() | void | Logs the resolved CSS inheritance chain for this section |
Listeners: onXXX(...) and section.track(off)
Every subscription of the framework — yojaWeb.onXXX, and the on… of every service
below — returns its off: a function that, called, stops the action from being
told (called again: nothing). There is no removeXXX(action): no function reference to keep, an
arrow function is fine.
The services live as long as the page; a section may not. The rule: a controller that subscribes to a
service hands the off to its section — section.track(service.onXXX(...)): it
runs once the section has left the page.
The problem it solves
A section can leave the page while the page goes on: a screen rebuilt, a list item removed, a dialog closed. Its subscriptions do not go with it — the service keeps the action, and through it the controller and its tags:
// ❌ without track
export default class CartLineControler {
constructor(section) {
yojaWebApi.eventService.on('cart:updated', cart => this.render(cart));
}
}
- the line removed from the cart, its action is still told on every
cart:updated: it renders tags no more in the page — or throws on them; - the cart screen rebuilt ten times,
cart:updatedis told ten times more, once per line ever built; - nothing of all these lines is ever freed: the service holds them.
// ✅ with track: the line removed, its action is never told again, and the line can be freed
export default class CartLineControler {
constructor(section) {
section.track(yojaWebApi.eventService.on('cart:updated', cart => this.render(cart)));
}
}
What to track
| Subscription | Track it? |
|---|---|
a service's onXXX(...) / on(...) — eventService, webSocketService, languageService, responsiveService, urlParameterService, storageService, httpClient | yes: the service outlives the section |
yojaWeb.onTagReady / onError from a controller | yes, the same |
addEventListener on the section's own tags | no: the listener goes with its tag |
section.controlerReady(...) / pageReady(...) | no: told once, they return no off (track of it: TypeError) |
How it works
export default class ChatControler {
constructor(section) {
const {webSocketService, languageService, responsiveService, eventService} = yojaWebApi;
section.track(webSocketService.onMessage('/ws/chat', message => this.show(message.data)));
section.track(languageService.onLanguageChange(() => this.refresh()));
section.track(responsiveService.onMedia(event => { section.tag.dataset.media = event.media.name; }));
// track returns the very same off: kept, it can still be called earlier, by hand
const offTyping = section.track(eventService.on('chat:typing', who => this.showTyping(who)));
section.firstTag('.mute').addEventListener('click', () => offTyping());
}
}
- When — no
MutationObserveris involved: before each event is told, by any service, the framework forgets the sections whose tag is no more in the page (isConnectedfalse) and runs their trackedoffs. An action of a section removed is never told — even when nothing else happened since its removal. - A section still loading (its controller, its CSS not there yet) is not touched.
- The section gone already when
trackis called (e.g. in athenafter it was removed): theoffruns at once. - The same
offis returned;off()called by hand then by the section: the second call does nothing. - Not a function:
TypeError, at once. - Moving a section out of the page and back between two events keeps it; out of the page while an event is told, it is forgotten.
1. the cart screen is built -> 3 lines, each tracks its on('cart:updated')
2. eventService.trigger('cart:updated') -> told to the 3 lines
3. line 2 is removed from the DOM -> nothing happens yet
4. eventService.trigger('cart:updated') -> first, line 2 forgotten: its off runs; then told to lines 1 and 3
5. the screen is rebuilt -> the old lines forgotten at the next event; only the new ones told
What every listener can count on
- Order — told in the order added (
eventService: in their position). - Isolation — an action throwing is logged and told to
yojaWeb.onError(...); the others are told all the same, and the code raising the event does not get the error. - Changes meanwhile — added while an event is told: told from the next one; removed meanwhile (its
off,removeAction,remove): not told, if not yet. - Checked at once — an action that is not a function is a
TypeErrorwhen subscribing.
section.controlerReady / pageReady are steps of the section's own life, not subscriptions: they return nothing.
YojaWebApi
httpClient service
Promise-based HTTP client. Content-Type is auto-detected from the body's runtime type. Exposes interceptors and an online/offline fallback.
Requests| Signature | Returns | Description |
|---|---|---|
get(request [, callback]) | Promise | GET — request is { url, headers? } or a URL string |
post(request, body [, callback]) | Promise | POST — Content-Type auto-detected from body type (JsonObject, Blob, string, …) |
load(request [, callback]) | Promise | GET that returns the response body as text |
fetch(request [, callback]) | Promise | Raw Fetch API passthrough |
| Signature | Returns | Description |
|---|---|---|
onRequest(callback) | off | Called before every outgoing request |
onResponse(callback) | off | Called after every response is received |
onFetch(callback) | off | Called for each Fetch-mode request |
addContentTypes(config) | void | Register custom MIME → parse-mode mappings (jsonContentTypes, textContentTypes, blobContentTypes, base64ContentTypes) |
| Signature | Returns | Description |
|---|---|---|
isOffline() | boolean | true when the browser has no network connection |
onOnline(callback) | off | Fires when the network connection is restored |
onOffline(callback) | off | Fires when the network connection is lost |
storageService service
Wrappers for localStorage and sessionStorage with typed accessors and change events. Item keys are namespaced (yojaWebItemKey__) and a per-scope key index is maintained.
Values are JSON-serialized with a type tag so the type is restored on read:
| Stored value | Restored as |
|---|---|
Date | a Date instance (revived from ISO) |
| plain object / array | the same structure (deep JSON copy) |
primitive — string / number / boolean / null | the same primitive |
undefined | stored as null |
Values must be JSON-serializable — function / Map / Set / Symbol are dropped, and a Date nested inside an object is restored as its ISO string.
| Signature | Returns | Description |
|---|---|---|
hasLocalItem(key) | boolean | Whether the key exists (distinguishes a stored falsy value from absent) |
getLocalItem(key) | any | Typed value, or undefined if absent |
getLocalItemKeys(query) | string[] | Sorted keys, optionally filtered by query |
setLocalItem(key, value) | void | Store a JSON-serializable value (see above) |
removeLocalItem(key) | void | Remove a single entry |
clearLocal() | void | Remove all local storage entries |
| Signature | Returns | Description |
|---|---|---|
hasSessionItem(key) | boolean | Whether the key exists (distinguishes a stored falsy value from absent) |
getSessionItem(key) | any | Typed value, or undefined if absent |
getSessionItemKeys(query) | string[] | Sorted keys, optionally filtered by query |
setSessionItem(key, value) | void | Store a JSON-serializable value (see above) |
removeSessionItem(key) | void | Remove a single entry |
clearSession() | void | Remove all session storage entries |
| Signature | Returns | Description |
|---|---|---|
on(scope, method, key, callback) | off | Per-key listener. scope: 'local'|'session'; method: 'get'|'set'|'has'|'remove'. callback(value) receives the value only. |
onEvent(callback) | off | Global listener. callback(scope, method, key, value) — positional args; method also includes 'clear' (fired as (scope, 'clear'), no key/value). |
eventService service
App-wide publish/subscribe bus. Events are identified by an eventId string; queries can target one or several events.
| Signature | Returns | Description |
|---|---|---|
on(eventId, action) | off | Subscribe action to eventId — a string, not a query; action: a function, or {label, position, action} |
trigger(query, parameter) | void | Publish to all events matching query, passing parameter; an action throwing goes to yojaWeb.onError, the others still told |
remove(query) | void | Remove matching events, their actions with them — one being told meanwhile tells no more of them |
| Signature | Returns | Description |
|---|---|---|
pause(query) | void | Pause matching events — triggers are silently dropped |
activate(query) | void | Resume paused events |
| Signature | Returns | Description |
|---|---|---|
has(query) | boolean | Whether at least one matching event exists |
event(query) | Event | First matching event descriptor |
events(query) | Event[] | All matching event descriptors |
actions(query) | Action[] | All subscribed actions across matching events |
count(query) | number | Number of matching events |
countAction(query) | number | Total number of subscribed actions |
webSocketService service
WebSocket client: one socket per URL of the application, on its own host and port, the URL as is. A socket closed -- by close(), by the server, the network, its opening timeout -- is over: its listeners are dropped, webSocket(url) gives a new one. Each on… returns its off; each event is told to the listeners in their order; a listener throwing does not keep the others from it.
| Signature | Returns | Description |
|---|---|---|
webSocket(url) | WebSocket | The socket of the URL: opened at once, the same until it is closed |
send(url, data) | Promise | Send text or binary data; rejected when it cannot open within its timeout (5s), or is closed |
close(url [, code [, reason]]) | Promise | Close it for good, once closed; its restart stopped |
autoRestart(url) | void | Cut otherwise than by close(), the same socket connects again, unseen: its listeners kept, no close / error told; 1s, 2s, 4s… up to 30s, at once when back online or shown; send() waits for it; restart told once connected |
stopAutoRestart(url) | void | No more restart; cut at the moment, the socket is closed for good (close told) |
| Signature | Returns | Description |
|---|---|---|
onOpen(url, callback) | off | Fires when the socket is opened |
onMessage(url, callback) | off | Fires on each incoming message |
onClose(url, callback) | off | Fires when the socket is closed |
onError(url, callback) | off | Fires on socket error |
onRestart(url, callback) | off | Fires when the socket is connected again after a cut (autoRestart) |
on(eventType, url, callback) | off | Any of open, message, close, error, restart |
Restart (auto)
A socket lives as long as its connection: the server restarted, a deploy, the Wi-Fi lost, the laptop asleep —
and it is over. Without restart, the application has to see the close, open a new socket and
subscribe all its listeners again. autoRestart(url) does it for it, unseen.
Cut otherwise than by close():
- the very same socket connects again: its listeners are kept; neither
close,errornor a secondopenis told — nothing to subscribe again; - when: after 1s, 2s, 4s, 8s… up to 30s between tries (each a part of it at random: the pages of a restarted server do not all come back at the same second); at once when the network comes back or the page is shown again; never while offline or hidden;
- meanwhile
send()andopen()wait for it, within their timeout (5s); - once connected again it tells
restart: the messages sent by the server during the cut are lost — the application reads its data again, by its REST API; close()stops it;stopAutoRestart(url)too — cut at the moment, the socket is then closed for good (closetold).
open ── message ── message ── ✂ cut ··· 1s ··· try ✗ ··· 2s ··· try ✓ ── restart ── message ...
(nothing told) (told once)
The rule of thumb: onMessage applies the changes, onRestart reloads the whole — the same code as the first load.
End to end: server and browser
The server (yoja-http-server) accepts only signed-in browsers — the handshake carries the session cookie — and broadcasts each change to every client connected:
HttpSessionStore sessions = new HttpSessionStore("session.tasks", Duration.ofDays(1));
WebSocket tasksSocket = WebSocket.asyncAccept("/ws/tasks", params ->
sessions.get(params.cookie(sessions.cookieName())) // no cookie: a null session
.map(session -> session != null && session.get(User.class) != null));
WebSocketService webSockets = new WebSocketService();
webSockets.add(tasksSocket);
HttpServer.builder(HttpRouter.builder().session(sessions) /* ...routes... */ .build(), 8080)
.webSocketService(webSockets)
.start();
// a task saved by the REST API: told to every browser connected
tasksSocket.send(JsonWriter.writeValue(Map.of("event", "saved", "task", task)));
The browser loads the tasks by REST, applies the changes received, and reloads everything after a cut:
export default class TaskBoardControler {
constructor(section) {
this.section = section;
const ws = yojaWebApi.webSocketService;
ws.autoRestart('/ws/tasks'); // server restarted, network back: connected again
section.track(ws.onMessage('/ws/tasks', message => this.apply(JSON.parse(message.data))));
section.track(ws.onRestart('/ws/tasks', () => this.load())); // sent meanwhile: lost, reload
section.track(ws.onClose('/ws/tasks', () => this.showOffline())); // closed for good (signed out)
this.load();
}
load() {
return yojaWebApi.httpClient.get({url: '/api/tasks'}).then(response => this.render(response.body));
}
apply(change) {
if (change.event === 'saved') this.renderTask(change.task);
}
}
- The board rebuilt, the old board's listeners are off (
track): the socket is shared, each message told once. - Signing out:
ws.close('/ws/tasks')— closed for good, not restarted; signed in again, the nextonMessageopens a new socket, accepted with the new session. - The server refusing the handshake: the socket is over —
closetold; unless it restarts: then it keeps trying, at most every 30s, until accepted.
navigationService service
Browser navigation and location helpers.
Navigation| Signature | Returns | Description |
|---|---|---|
load(url [, parameters]) | void | Navigate to url (window.location.assign), optionally merging parameters |
reload() | void | Reload the current page |
back() | void | history.back() |
forward() | void | history.forward() |
go(delta) | void | history.go(delta) |
| Signature | Returns | Description |
|---|---|---|
path() | string | Current window.location.pathname |
fragment() | string | Current window.location.hash |
host() | string | Current hostname |
port() | string | Current port |
urlParameter() | UrlParameter | Parsed current query string |
urlParameterService service
Read and write URL query parameters with history management.
Read| Signature | Returns | Description |
|---|---|---|
has(key [, value]) | boolean | Whether the key (optionally with value) is present |
get(key) | string | First value for the given key |
getAll(key) | string[] | All values for the given key |
keys() | string[] | All parameter names |
entries() | Entry[] | All key/value entries |
currentUrlParameter() | UrlParameter | Current parsed URL parameters snapshot |
toUrlQuery() | string | Render current params as a raw query string |
getHash() | string | In-memory hash fragment (without the leading #) |
currentUrlHash() | string | Cleaned live window.location.hash |
isUpdated() | boolean | true when the live URL is in sync with the in-memory params and hash (nothing left to push/replace) |
state() | HistoryState | Current history state object |
| Signature | Returns | Description |
|---|---|---|
set(key, value) | void | Set (replace) a parameter value |
append(key, value) | void | Add a value without removing existing ones |
remove(key [, value]) | void | Remove a parameter (or a specific value) |
clear() | void | Remove all parameters (also clears the hash) |
setHash(hash) | void | Set the in-memory hash fragment (leading # stripped) |
removeHash() | void | Clear the in-memory hash fragment |
push(data) | void | Commit current params + hash to a new history entry (optional state data) |
replace(data) | void | Commit current params + hash to the current history entry (optional state data) |
back() | void | Native history back |
forward() | void | Native history forward |
go(delta) | void | Native history go — integer delta only |
onChange(callback) | off | Fires with an event object on every change; return false from a before-* event to cancel it |
UrlParameter type
Ordered, multi-valued query-string model returned by currentUrlParameter() and navigationService.urlParameter(). An Entry is { key: string, value: string }; empty values are normalised to null.
HistoryState type
Immutable snapshot stored in the History API by push() / replace() and returned by state(). Holds the user data payload, a cloned UrlParameter, the hash fragment, and the resolved URL.
languageService service
Internationalisation. Loads XML translation files and retranslates the page on language change.
Language| Signature | Returns | Description |
|---|---|---|
setLanguage(language) | void | Set the active language code (e.g. 'en', 'fr') |
getLanguage() | string | Active language code |
onLanguageChange(action) | off | Fires when the language is changed |
refresh([language]) | Promise | Re-translate the whole page; defaults to current language |
refreshFrom(tags [, language]) | Promise | Re-translate a specific set of elements |
onLanguageTranslate(action) | off | Fires after each translation pass |
loadTranslator(path) | void | Load an XML translation file at path |
log(path) | void | Log all translation keys defined in the file at path |
responsiveService service
Viewport breakpoint detection. Breakpoints are declared in YojaWeb.conf.js via initialize().
| Signature | Returns | Description |
|---|---|---|
getMedia() | MediaDescription | null | The currently active breakpoint, {name, maxWidth} |
getListOfMedia() | MediaDescription[] | All defined breakpoints, smallest first |
findMedia(mediaName) | MediaDescription | Descriptor for the named breakpoint |
onMedia(callback) | off | Fires on every breakpoint change with {event: 'media', previousMedia, media, width, height} |
onResize(callback) | off | Fires on every window resize with {event: 'resize', media, width, height} |
initialize(mediaDescriptions) | void | Configure breakpoints — typically called once from YojaWeb.conf.js |
Module README (much more depth): yoja-web/README.md. It walks through every directive, the section lifecycle, the full service surface, and the path-resolution rules.