From f4c4030cf6e192217a53c470674a14f811868b7a Mon Sep 17 00:00:00 2001 From: Florian Zschocke Date: Mon, 21 Nov 2022 20:52:10 +0100 Subject: Replace SWF clippy with clipboard.js on ticket page The ticket page also has some copy-to-clipboard buttons, which get updated to work with JS instead of SWF. --- .../java/com/gitblit/wicket/pages/TicketPage.html | 20 +++++++------------- .../java/com/gitblit/wicket/pages/TicketPage.java | 11 +++++------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.html b/src/main/java/com/gitblit/wicket/pages/TicketPage.html index 46c0f7ee..fd64b776 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.html +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.html @@ -586,20 +586,14 @@ pt push - - - - - + + + + + + + diff --git a/src/main/java/com/gitblit/wicket/pages/TicketPage.java b/src/main/java/com/gitblit/wicket/pages/TicketPage.java index 1750b859..d6d188df 100644 --- a/src/main/java/com/gitblit/wicket/pages/TicketPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TicketPage.java @@ -102,7 +102,6 @@ import com.gitblit.wicket.panels.CommentPanel; import com.gitblit.wicket.panels.DiffStatPanel; import com.gitblit.wicket.panels.IconAjaxLink; import com.gitblit.wicket.panels.LinkPanel; -import com.gitblit.wicket.panels.ShockWaveComponent; import com.gitblit.wicket.panels.SimpleAjaxLink; /** @@ -1644,12 +1643,12 @@ public class TicketPage extends RepositoryPage { protected Fragment createCopyFragment(String wicketId, String text) { if (app().settings().getBoolean(Keys.web.allowFlashCopyToClipboard, true)) { - // clippy: flash-based copy & paste + // javascript: browser JS API based copy to clipboard Fragment copyFragment = new Fragment(wicketId, "clippyPanel", this); - String baseUrl = WicketUtils.getGitblitURL(getRequest()); - ShockWaveComponent clippy = new ShockWaveComponent("clippy", baseUrl + "/clippy.swf"); - clippy.setValue("flashVars", "text=" + StringUtils.encodeURL(text)); - copyFragment.add(clippy); + ContextImage img = WicketUtils.newImage("copyIcon", "clippy.png"); + // Add the ID of the target element that holds the text to copy to clipboard + img.add(new SimpleAttributeModifier("data-clipboard-text", text)); + copyFragment.add(img); return copyFragment; } else { // javascript: manual copy & paste with modal browser prompt dialog -- cgit v1.2.3