| Artifact ID: | cda12242450204bcb2e871b15c3869fddc47fccd82095cae0eb90ac1d102681c |
|---|---|
| Page Name: | branch/copybtn.js-responsive |
| Date: | 2025-08-12 15:38:01 |
| Original User: | florian |
| Mimetype: | text/x-markdown |
| Parent: | d49ee2b2caca8ddc83a57e8f6f75468f6f795b0d53b956014251eacd478c6142 (diff) |
Cross-reference to Forum Post: [Revamped Copy Buttons (Web UI)] (forum:/forumpost/cf327708cf)
The Copy Buttons (to copy text to the clipboard in the web UI) are changed from
<span>elements to<button>elements containing a nested<span>. This allows definition of the "pushed" look throughbutton:activeby CSS, obsoleting the corresponding JS code and the hard-codedopacityanimation. Like this, the transition from "normal" to "pushed" already happens on theonmousedownevent instead of on theonmouseupevent (when the click event is "complete" and triggers theonclickhandler), resulting in a more responsive user experience -- the main motivation behind this change.All JS code paths to initialize Copy Buttons automatically create the nested
<span>element if the<button>doesn't yet have any child nodes. However, where possible, the nested<span>is already generated on the server-side as static HTML so that the Copy Buttons are still visible in case of JS errors (which probably only makes sense for Fossil JS hackers).The layout of the new
<button>-based variant is compatible with the previous<span>-based variant in Chrome/FF/IE, except for some barely noticeable horizontal deviation of a single pixel or two, likely due to font size differences of the<button>element (despitefont-size: inherit).