1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-10-01 08:20:46 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/mechanisms/PopupMechanism.tid
FlashSystems 5b85786f73
Fix popup position if popup is triggered from within an offsetParent element (#6887)
* Fix popup location for tables

This commit introduces the `popupAbsCoords` option to the $button widget
and implements an absolut coordinate format.

Coordinates for popups are stored in the format `(x,y,w,h)`. These
coordinates are relative to the offset parent of the element that
defines the popup.

This commits adds a second format `@(x,y,w,h)`. Coordinates specified in
this format a relative to the pages root element.

The `popupAbsCoords` option of the $button widget enables the use of
this coordinates.

* Unify the declaration of the RegEx for parsing the popup-position

The regular expression was declared in three locations with the same
content. This commit supplies a new function `parseCoordinates` in
`popup.js`. This function returns the parsed coordinates and understands
the classic/absolute coordinates.

This function is used in `reveal.js` and `action-popup.js` to parse the
coordinates.

* Add documentation for coordinate systems

* Consolidate creating coordinate strings

The Popup object now contains a `buildCoordinates` method that can be
used to build coordinate strings. It takes an "enum" for the coordinate-
system to use. This makes everything easily extensible and prevents the
use of magic values.

* Add tests for `parseCoordinates` and `buildCoordinates`

* Add `tv-popup-abs-coords` to `collectDOMVariables`

This will make the absolute coordinates available for the
`DraggableWidget` and the `EventCatcherWidget`.

* Add documentation for the `tv-popup-abs-coords`

... to the `DraggableWidget` and the `EventCatcherWidget`.
2022-10-22 13:13:39 +01:00

16 lines
810 B
Plaintext

created: 20131212175656755
modified: 20151223222712715
tags: Mechanisms
title: PopupMechanism
type: text/vnd.tiddlywiki
The popup mechanism allows blocks of content to be selectively displayed and positioned with respect to an anchor. It has several parts:
* [[StateTiddlers|StateMechanism]] to record whether a popup is currently displayed or not
* The RevealWidget to selectively display the popup content
** <<.from-version "5.2.4">> For positioning the popups relative or absolute coordinates can be used. See [[Coordinate Systems]] for more information about usage and format.
** For "sticky" popups — those that don't close when clicking inside one — set the ''class'' attribute to `tc-popup-keep`
* The ButtonWidget to trigger the display of the popup by setting the state tiddler appropriately