Repository navigation
Floating Windows Developer Guide
How one window and one file viewer are shared between the Files module and Tickets, and how to use them on another page. Added in 4.4.0 for #226, where a picture on a ticket note replaced the whole Tickets page.
In one sentence: the window (drag, resize, snap, maximise) is float-window.js; the viewer (pictures, PDFs, Word, spreadsheets...) is files-viewer.js; Files adds a taskbar on top, and any other page gets the same window floating over itself.
For the Files desktop itself (taskbar, previews, menus) see Files developer guide Β§10. For the rest of the Tickets page see the Inbox.js map.
| File | What it holds | Used by | |
|---|---|---|---|
| πͺ | assets/js/float-window.js |
The window. Title bar, drag, resize from 8 handles, snap (top = maximise, sides = half), double-click to maximise, focus and z-order, keeping windows on screen when the browser shrinks. FloatWin.manager() and FloatWin.page(). |
Files, Tickets |
| π₯οΈ | assets/js/files-wm.js |
The desktop half. A taskbar button per window, minimise to it, hover previews, menus, dialogs, notifications, clock, navbar. Builds on FloatWin.manager() through hooks. |
Files only |
| π | assets/js/files-viewer.js |
The viewer. renderInto() draws a file into any element. FilesViewer.open(id) for a Files file; FilesViewer.openUrl({...}) for anything else. Libraries (pdf.js, mammoth, SheetJS) load on first use. |
Files, Tickets |
| π¨ | assets/css/float-window.css |
The window (.fd-win, .fd-titlebar, .fd-rs-*), the viewer (.fdv-*) and .fw-layer
|
Files, Tickets |
| π¨ |
assets/css/mobile.css 45d |
The phone viewer (.fdm-viewer) - full screen with Back. Not scoped to any page. |
Files, Tickets |
| π£ | assets/js/files-icons.js |
File-type icons for the window's title bar | Files, Tickets |
| π€ | lang/en/files.php |
The strings: wm.* (window buttons), viewer.*, loading, ex.download
|
Files, Tickets |
The class names are fd-* and fdv-* on every page, because Files had them first. Renaming them would have meant touching every Files rule for no behaviour change.
A manager owns the windows in one area. There are two kinds:
| Files desktop | Any other page | |
|---|---|---|
| Made by |
FloatWin.manager({...}) in files-wm.js
|
FloatWin.page() - made on first use |
| Area |
#fdDesktop, between the header and the taskbar |
.fw-layer, a fixed layer over the viewport (z-index: 5000) that lets the pointer through everywhere except on a window |
| Minimise | yes, to the taskbar | no button - nothing to minimise to |
| Escape | Files' own keys | closes the window in front |
files-wm.js passes hooks; the window calls them at the right moments:
var mgr = window.FloatWin.manager({
area: desktop,
ghost: ghost,
minimise: true,
L: L,
/** A minimised window shrinks into, and grows back out of, its taskbar button. */
taskRect: function (w) { return w.btn.getBoundingClientRect(); },
/** Gives a new window its taskbar button. */
onCreate: function (self) { /* builds self.btn, its click / hover / right-click */ },
onFocus: function (w) { w.btn.classList.add('fd-active'); },
onBlur: function (w) { w.btn.classList.remove('fd-active'); },
onMinimise: function (w) { w.btn.classList.add('fd-min'); },
onRestore: function (w) { w.btn.classList.remove('fd-min'); },
onClose: function (w) { hidePreview(); w.btn.remove(); },
onGeometry: function (kind, geo) { if (geometryHook) geometryHook(kind, geo); }
});FilesWM.open(), windows() and active() are now one-line pass-throughs to mgr, so nothing in files-desktop.js changed.
Rule of thumb: if a feature needs a taskbar, it belongs in files-wm.js. If a window on any page would want it, it belongs in float-window.js.
FilesViewer.openUrl({ name, src, downloadUrl, size, key })| Option | Meaning |
|---|---|
name |
The file name. The extension decides the kind - .pdf is drawn by pdf.js, .png as a picture, and so on. |
src |
An address the caller already has, and has already permission-checked. The viewer fetches it as it is. |
downloadUrl |
Optional. Gives the window a Download button, with the download attribute set (see Traps). |
size |
Optional. Shown when there is no preview. |
key |
Optional, defaults to src. A second openUrl with the same key brings the existing window to the front instead of opening another. |
It returns the window, or null for a kind the viewer cannot show - so the caller falls back to its old behaviour. On a phone (β€ 768px) it opens the full-screen viewer instead and returns that.
The point of openUrl is that it never asks Files for anything. FilesViewer.open(id) goes through api/files/view.php and Files' folder permissions; openUrl uses whatever address the caller passes, so the caller's own permission check is the one that applies.
assets/js/inbox.js. One list decides what Tickets sends to the viewer:
// The files Tickets opens in the Files viewer: pictures and PDFs. The viewer can show
// more (Word, spreadsheets, zips...) - Ed chose these two. SVG is deliberately absent:
// it can carry script.
const VIEWER_FILE_RE = /\.(png|jpe?g|gif|webp|bmp|pdf)$/i;Files on a note - renderNotes() marks a matching file's link with data-view-file, and one delegated click handler on #notesContainer opens it:
function openNoteFile(ev) {
const a = ev.target.closest('a.note-file[data-view-file]');
if (!a || ev.button !== 0 || ev.ctrlKey || ev.metaKey || ev.shiftKey || ev.altKey) return;
if (!window.FilesViewer || !window.FilesViewer.openUrl) return;
const href = a.getAttribute('href');
const w = window.FilesViewer.openUrl({
name: a.dataset.viewFile, src: href, downloadUrl: href, size: Number(a.dataset.size) || 0
});
if (w) ev.preventDefault();
}The link stays a real link to api/documents/download.php: Ctrl-click and middle-click still open a new tab, and only a plain click is taken over.
Email attachments - every way of opening one (the Attachments list's rows, its thumbnails, the phone's cards) goes through openAttachment(id):
function openAttachment(attachmentId) {
const url = `${API_BASE}get_attachment.php?id=${attachmentId}`;
const att = (ticketAttachments || []).find(a => Number(a.id) === Number(attachmentId));
if (att && VIEWER_FILE_RE.test(att.filename || '') && window.FilesViewer && window.FilesViewer.openUrl) {
// openUrl decides by the file NAME (and never shows SVG); null = not a kind it shows.
if (window.FilesViewer.openUrl({ name: att.filename, src: url, downloadUrl: url, size: att.file_size || 0 })) return;
}
window.open(url, '_blank');
}To show more kinds in Tickets (Word, spreadsheets, text), add the extensions to VIEWER_FILE_RE - nothing else. Zips need a guard first: opening something inside a zip calls auditEntry(), which writes to Files' audit log by Files id - a ticket attachment has none.
-
CSS, before the page's own sheet:
<link rel="stylesheet" href="../assets/css/float-window.css?v=1">
-
Scripts, in this order, before the page's own script:
(Check the current
<script src="../assets/js/float-window.js?v=1"></script> <script src="../assets/js/files-icons.js?v=2"></script> <script src="../assets/js/files-viewer.js?v=8"></script>
?v=numbers intickets/index.php- grep, never recall.) -
Strings - export only the viewer's, not the whole 28 KB Files namespace. From
tickets/index.php:$jsTranslations = I18n::exportForJs($translationNamespaces); $filesStrings = I18n::exportForJs(['files'])['files'] ?? []; $jsTranslations['files'] = array_intersect_key($filesStrings, array_flip(['wm', 'viewer', 'loading'])) + ['ex' => ['download' => $filesStrings['ex']['download'] ?? 'Download']];
-
Call
FilesViewer.openUrl()with an address your page already permission-checks, and fall back when it returnsnull. -
Just a window, no viewer?
FloatWin.page().open({ title, width, height, onClose })returns a window; put your content inwin.body.
The phone viewer needs nothing extra - mobile.css 45d is not scoped to a page.
| Where | Trap |
|---|---|
files-viewer.js (top) |
The base must be absolute. pdf.js loads with import(), which resolves a relative path against the script's address, not the page's. A base of '../' from assets/js/ pointed at assets/assets/js/vendor/. Pictures never noticed, because <img> resolves against the page. Outside Files the base comes from the viewer's own script URL. |
files-viewer.js renderImage()
|
Refit just after the ResizeObserver, never inside it. Resizing the picture adds or removes the stage's scrollbars, which resizes the stage again inside the same callback - "ResizeObserver loop completed with undelivered notifications" - and the notifications the browser drops are real window resizes that never refit. A 16ms timer, as the PDF view uses 120ms. |
files-viewer.js Download |
Set download on the link. openUrl's address may serve a picture to show (both ticket endpoints do), so without it "Download" opened the picture in the tab - the bug #226 was about. |
float-window.js Escape |
Escape closes the window in front, and only when focus is not in a text field elsewhere on the page - that Escape belongs to whatever is being typed. openUrl focuses the window's stage on opening, so Escape works straight away. |
float-window.js / files-wm.js
|
Load float-window.js first. files-wm.js and files-viewer.js read window.FloatWin as they load. |
.fw-layer |
pointer-events: none on the layer, auto on its children - otherwise the invisible layer swallows every click on the page. |
Headless Chrome with a virtual clock (--virtual-time-budget) cannot judge any of this reliably. It does not lay the page out between script steps, so a ResizeObserver fired or not depending on whether the test happened to read a size, close animations never finished, and requestAnimationFrame never ran. The same build passed, failed and half-passed on three runs.
Run it in real time and read the console as it happens:
timeout 40 chrome --headless=old --disable-gpu --no-sandbox \
--enable-logging=stderr --log-level=0 --window-size=1450,950 \
--remote-debugging-port=9333 --user-data-dir=<scratch>/prof \
http://localhost/freeitsm/<harness>.html 2> log.txt
grep -o 'HARNESS [^"]*' log.txtThe debugging port keeps Chrome alive (--dump-dom and --screenshot both end the run at page load); timeout stops it. The harness loads the real page in a same-origin iframe, clicks the real links, and console.error('HARNESS ...')s what it finds. Count open windows with FloatWin.page().windows(), not .fd-win elements - a closed window's element lingers while it fades.
What was proved for 4.4.0, on real tickets: the #226 write-up.
FreeITSM β an open-source IT Service Management platform Β· github.com/edmozley/freeitsm Β· MIT licence
- Installation
- β° Scheduled tasks (cron jobs)
-
Architecture
- β³ π§Ή Root folder tidy (URL routing)
- β³ π Database Integrity (FKs & constraints)
- β³ π οΈ Database Verification β Developer Guide
- β³ π§© Service Layer (UI + API share code)
- β³ πͺ€ Code traps (the TRAP: comments)
- β³ π Commenting for the Engineering wiki
- β³ π οΈ Engineering wiki scanner - Developer Guide
- β³ π Service-Layer progress
- π€ Contributing (read before a pull request)
- π§ͺ Developer tests
- AI Providers
- Internationalisation (i18n)
- Timezones & Time Handling
- π Date & Time Formats
- π± Currencies
- π§ The sidebar (optional module rail)
- π§© Preference templates
- π Display order (modules, Watchtower cards) β Developer Guide
- Theming & Dark Mode
- ποΈ Recent β getting back to what you were doing
- β¨οΈ Command palette (βK)
- π Searching inside tickets
- π Attached documents
-
MobileβFriendly
- β³ π« Mobile: Tickets
- β³ π» Mobile: Assets
- β³ π Mobile: Calendar
- β³ π Mobile: Knowledge
- β³ π¦ Mobile: Service Status
- β³ πΌ Mobile: Watchtower
- β³ π§© Mobile: Problem Management
- β³ π Mobile: Change Management
- β³ πΏ Mobile: Software
- β³ β Mobile: Tasks
- β³ π Mobile: Forms
- β³ π Mobile: Contracts
- β³ π Mobile: Domains
- β³ π Mobile: People
- β³ π Mobile: Projects
- β³ ποΈ Mobile: Files
- β³ π Mobile: LMS
- β³ πΊοΈ Mobile: CMDB
- β³ πΊοΈ Mobile: Network Mapper
- β³ π§ Mobile: Process Mapper
- β³ βοΈ Mobile: Workflow
- β³ π₯οΈ Mobile: System
- β³ π Mobile: Reporting
- β³ π Mobile: System Wiki
- β³ π Mobile: Self-Service Portal
- β³ π§° Mobile: Techniques & Tricks
-
Security
- Layer 1 β which modules you can enter
- β³ π§© Module Access Control
- β³ π οΈ Module Access β Developer Guide
- β³ π Switching modules off
- β³ π οΈ Module availability β Developer Guide
- β³ π Module availability β design (#217)
- Layer 2 β what you can administer
- β³ π Roles & Permissions
- β³ π οΈ Roles β Developer Guide
- β³ π€ Why capabilities are constants
- Layer 3 β the System module
- β³ π Admin Access Control
- Hardening
- β³ π Security review response 2026-08
- β³ π‘οΈ Security hardening 2026-08
- β³ π οΈ Security hardening 2026-08 β Developer Guide
- β³ π‘οΈ Round three β plain English
- β³ π οΈ Round three β Developer Guide
- β³ π‘οΈ CSRF protection (S4) β Developer Guide
- Single Sign-On (SSO)
- ποΈ LDAP & Active Directory
- π CardDAV contact sync
- Browser Extension
- API Reference
-
π REST API β how it works
- β³ π Proposal: custom fields, inventory import and change evidence (#194)
- β³ π οΈ Custom fields, evidence + inventory - review (#195-#197)
- β³ π οΈ Long forms in a task's Work view - review (#198)
- β³ π« REST API: Tickets
- β³ π» REST API: Assets
- β³ π΄ REST API: Problems
- β³ π REST API: Changes
- β³ π REST API: Knowledge
- β³ β REST API: Tasks
- β³ ποΈ REST API: CMDB
- β³ π REST API: Contracts
- β³ ποΈ REST API: Calendar
- β³ πΏ REST API: Software
- β³ π REST API: Domains
- β³ π¦ REST API: Service Status
- β³ βοΈ REST API: Morning Checks
- β³ π REST API: Forms
- β³ βοΈ REST API: Workflow
- β³ π·οΈ REST API: Cost centres
- β³ π§βπΌ REST API: Analysts
- β³ πΊοΈ REST API: Network Mapper
- β³ π§ Using the API docs page
- β³ π OpenAPI specification
- β³ β OpenAPI: kept correct
- β³ π οΈ Maintaining the catalogue
- Watchtower
-
Tickets
- β³ π οΈ Inbox.js map β Developer Guide
- β³ π οΈ Floating windows & the file viewer β Developer Guide
- β³ π οΈ Tickets settings β Developer Guide
- β³ ποΈ The ticket workspace
- β³ π The ticket table
- β³ π Rota copy and paste β Developer Deep Dive
- β³ β Checklists & SOPs
- β³ βοΈ Mandatory fields
- β³ π§Ύ Custom ticket fields
- β³ π·οΈ Ticket categories
- β³ π₯ Assigning tickets to a team, and escalation
- β³ π’ One board across every company
- β³ Mailbox Authentication
- β³ π€ Email send log
- β³ π Attachment size limits and large emails
- β³ Basic IMAP mailboxes
- β³ Email rendering & images
- β³ SLA Management
- β³ WhatsApp channel
-
β³
βοΈ Telegram channel - β³ β CSAT company scope and filters β Developer Guide
- β³ π₯ Microsoft Teams channel
- β³ π¨οΈ Mattermost channel
- β³ π¬ Web chat channel
- β³ π£ Slack channel
- β³ π Linking tickets
- β³ β Record previews
- β³ π Ticket notes: internal or shared
- β³ ποΈ Canned responses
- β³ βοΈ Limiting replies to particular senders
- β³ π¨ Telling the analyst a ticket is theirs
- β³ βοΈ Email signatures
- β³ π The public web address
- β³ π’ Ticket numbering
- β³ π Raising a ticket for someone else
- β³ π Merging tickets
- β³ π Confidential tickets
- β³ π₯ Portal managers
- β³ π Who has seen a ticket
- β³ π Reading long tickets
- β³ β Splitting tickets
- β³ β Selecting several tickets
- β³ ποΈ The folder pane
- β³ π½ Just my tickets, or no closed ones
- β³ π οΈ Snoozing tickets β Developer Guide
- β³ π₯ Collision detection
- β³ β±οΈ Time tracking
- β³ π Case reports - a ticket and its work as one PDF
- β³ π Scheduled work in your own calendar
- Problem Management
- Tasks
- π Projects
-
Assets
- β³ π’ Moving an asset between companies
- β³ π Shared asset locations
- β³ π§βπΌ Assigning assets to analysts
- β³ π Warranty and lease alerts
- β³ π Leases
- β³ π Saved table views
- β³ π¨οΈ Recording anything, and importing it
- β³ π§© Asset type layouts
- β³ π Inventory freshness
- β³ π Linked configuration item
- β³ π Connected assets
- β³ π Asset review
- β³ π·οΈ QR asset labels
- β³ π Who holds what, and handover documents
- β³ π₯οΈ The inventory agent (PowerShell)
- β³ ποΈ Proxmox VE servers
- β³ βοΈ VMware Cloud Director servers
- β³ πͺ Hyper-V and Failover Clusters
- β³ π Linking equipment to tickets
- β³ βοΈ Follow-up tasks on a ticket
- Knowledge
- Change Management
- Calendar
- Morning Checks
- Reporting
- Software
-
Forms
- β³ π¨ The form designer β Developer Guide
- β³ π Layout & the grid β Developer Guide
- β³ ποΈ Collections β grouping submissions
- β³ π Submissions as PDFs
- β³ β‘ What happens next β a form's own actions
- β³ π οΈ Sections & conditional logic β Developer Guide
- β³ π οΈ Lookup fields β Developer Guide
- β³ π‘οΈ Catalogue request approvals
- People
- Domains
- ποΈ Files
- Contracts
- Service Status
- π Notifications
- π¨ War Room
- Self-Service Portal
- LMS
- Process Mapper
- CMDB
- Network Mapper
- Workflows
- Issue trackers (Jira, Azure DevOps)
- π‘ Zabbix (monitoring)
- π¬ Microsoft Teams alerts
- π 3CX (phone system)
-
System
- β³ π οΈ Preferences β Developer Guide
- β³ π Finding people in the Analysts list
- β³ πͺ When an analyst leaves
- β³ π οΈ System β Branding β Developer Guide
- β³ π©Ί Page health (D019) β Developer Guide
- β³ β Feature Bingo
- β³ π·οΈ Cost centres
- β³ π· Photo Album
- β³ Demo Data
- β³ π οΈ Demo Data β Developer Guide
-
Overview
- β³ π Progress tracker
- β³ Concepts & vocabulary
- β³ Email routing & mailboxes
- β³ Settings: global vs per-company
- β³ Users & self-service
- β³ Staff cross-company access
- β³ π’ One board across every company
- β³ Worked examples
- β³ Pitfalls & gotchas
- β³ Scope: what it's for
- β³ π οΈ Developer Guide (make a module multi-company)
- β³ ποΈ Case study: CMDB (a linked graph)
- β³ π§ͺ Test harness (prove it's isolated)
- What this is
-
π Bugs resolved
- β³ π« #226 A picture on a note could not be closed
- β³ π» #222 The Assets page never loaded in 4.3.0
- β³ βοΈ #214 A "contains" condition did not match capitals
- β³ βοΈ #216 A workflow email from a chosen mailbox always failed
- β³ π³ The Docker image was missing PHP extensions
- β³ π A failed DNS lookup read as a missing record
- β³ π A link could change data
- β³ π Access outlived its removal
- β³ π Knowledge articles could run scripts
- β³ π Knowledge writes ignored permissions
- β³ π Company boundaries (Oct 2026)
- β³ π Smaller gaps (Oct 2026)
- β³ π Escaped text could leave its attribute
- β³ π Task descriptions were not cleaned
- β³ π Task documents ignored company scope
- β³ π Repeating tasks ignored company scope
- β³ π¬ #183 Mailbox checks overlapped
- β³ π #188 Transfer lock shown off when unknown
- β³ β #184 Subtask names and Overdue
- β³ π§© #186 Teams: the buttons did nothing
- β³ π Text in a change could run script
- β³ π AI settings changed without the AI permission
- β³ πͺ #178 Deleting an analyst failed
- β³ π« A team with no departments showed 0 tickets
- β³ π Projects: adding a phase did nothing on Save
- β³ π Leavers could still sign in
- β³ πΌοΈ Logo and courses broke on Apache with PHP-FPM
- β³ π’ Chat tickets ignored your ticket numbering
- β³ π Dates shown as a dash, or in server time
- β³ π Assets β Users showed people from other companies
- β³ π Restricted analysts could read other modules' data
- β³ πΌοΈ Replies with a picture in the thread failed to send
- β³ π Reply attachments never reached the customer
- β³ π οΈ Outbound email attachments β Developer Guide
- β³ π A global SSO provider was missing from the portal
- β³ π Behind a proxy, the SSO redirect said http
- β³ βοΈ The portal tagline moved when you saved it
- β³ π¨ The portal settings screen forgot what you saved
- β³ π‘οΈ The approvals inbox said "Error" and nothing else
- β³ π A table's answers were missing from the PDF
- β³ β A single-select column let you tick every option
- β³ π The portal ignored a form's field widths
- β³ π The tasks board stopped taking clicks
- β³ ποΈ #121 The index list is out of date after upgrading
- β³ π #133 The calendar subscription was empty
- β³ π #131 Tasks always reopened on the board
- β³ π₯ #129 Every page returned HTTP 500 after upgrading
- β³ π³ #127 A PHP warning above the System page
- β³ π #126 Notes stamped with the server's clock
- β³ π Storing every date in UTC
- β³ πͺ The portal was down for everyone signed in
- β³ βοΈ #120 Workflow notes could never be written
- β³ βοΈ #123 Three errors when running Database Verification
- β³ π #122 The description box was a stub in the corner
- β³ π£ Demo data deleted real accounts
- β³ π #117 Sign-in redirected to the wrong address
- β³ π¨ #108 The priority dot was invisible
- β³ β±οΈ #116 Time logged from the right-click menu
- β³ π #114 API keys refused by our own guard
- β³ ποΈ #110 Assigning a task told nobody
- β³ πͺ #107 Signed out while still working
- β³ π #103 "Share with Requester" reached nobody
- β³ π #102 Search found nothing for hyphens
- β³ πͺ #101 Source code editor opened behind
- β³ βοΈ #88 Subtasks could not be ticked off
- β³ π» #84 Asset deep link selected nothing
- β³ π« #79 A new ticket arrived with no status
- β³ π§ #79 A ticket from email did not say so
- β³ π #78 Bell opened to nothing
- β³ π¬ #77 Mail only collected from Inbox
- β³ π #74 The default password could not be changed
- β³ π¦ #70 Renaming an impact level
- β³ π€ #67 App-only mailboxes could not send
- β³ π #45 Verify only ever worked for Microsoft
- β³ π #45 IMAP reported as not authenticated
- β³ βοΈ An email template stopped escaping itself
- β³ π The portal dashboard showed the wrong time
- β³ π’ The folder said 99 and the list showed 96