| Property | Value |
|---|---|
| Plugin ID | net.markus-michalski:tab-swap |
| Name | Tab Swap |
| Plugin class | TabSwapPlugin in class.TabSwapPlugin.php |
| Configuration class | TabSwapConfig in config.php |
| Instances | Singleton: exactly one instance, enable() creates it if needed |
| PHP | >=7.4 (composer.json) |
bootstrap() calls checkVersion(). If installed_version is empty or lower than the version from plugin.php, performUpdate() writes the new version to the configuration. A message goes to the error log only if the DEBUG constant is set and truthy.onObjectView() to the object.view signal.onObjectView() only acts if the passed object is a Ticket (for example not a task). In that case the script is output.The plugin outputs an element of the form <script data-plugin="tab-swap" data-version="..." nonce="...">:
data-version holds installed_version, but only if the value matches the pattern number.number or number.number.number. Otherwise 1.0.0 is used. The value is also HTML-escaped.nonce is only set if the CSP_NONCE constant is defined. The value is HTML-escaped.The script only acts once all prerequisites are met:
#post-reply-tab, #post-note-tab, #reply and #note exist.offsetParent is not null).Then the following happens:
li element of the note tab is moved before the li of the reply tab inside #response-tabs.active is removed from the reply tab and aria-selected="false" is set. On the note tab, active is added and aria-selected="true" is set.#reply gets display: none, #note gets display: block.The swap runs once per page build. So that it also applies to pages built later, the script uses:
MutationObserver that waits for #post-reply-tab and stops after a successful swap,DOMContentLoaded,pjax:success and, if jQuery is present, the redraw.staff event. In both cases the state is reset and the swap runs again.jQuery is not strictly required. Without it, only the reaction to redraw.staff is omitted.
tab-swap/
├── plugin.php # plugin metadata
├── class.TabSwapPlugin.php # plugin class, signal handler, inline script
└── config.php # TabSwapConfig with the two fields
The repository additionally contains composer.json, PHPUnit tests, a CI workflow and documentation. CI checks syntax and runs the tests with PHP 7.4 to 8.3.