]> source.dussan.org Git - gitblit.git/commitdiff
Replace SWF clippy with clipboard.js on ticket page
authorFlorian Zschocke <f.zschocke+git@gmail.com>
Mon, 21 Nov 2022 19:52:10 +0000 (20:52 +0100)
committerFlorian Zschocke <f.zschocke+git@gmail.com>
Sat, 3 Dec 2022 13:33:31 +0000 (14:33 +0100)
The ticket page also has some copy-to-clipboard buttons, which get
updated to work with JS instead of SWF.

src/main/java/com/gitblit/wicket/pages/TicketPage.html
src/main/java/com/gitblit/wicket/pages/TicketPage.java

index 46c0f7ee3a0de29fbc5947773109f027ca375838..fd64b77648ab4f3418a90efbe3fed83ff2af09c8 100644 (file)
@@ -586,20 +586,14 @@ pt push</pre>
                <img wicket:id="copyIcon" wicket:message="title:gb.copyToClipboard"></img>\r
        </span>\r
 </wicket:fragment>\r
-    \r
 \r
-<!-- flash-based button-press copy & paste -->\r
-<wicket:fragment wicket:id="clippyPanel">\r
-       <object wicket:message="title:gb.copyToClipboard" style="vertical-align:middle;"\r
-                       wicket:id="clippy"\r
-                       width="14" \r
-                       height="14"\r
-                       bgcolor="#ffffff" \r
-                       quality="high"\r
-                       wmode="transparent"\r
-                       scale="noscale"\r
-                       allowScriptAccess="sameDomain"></object>\r
-</wicket:fragment>\r
+\r
+       <!-- JavaScript automatic copy to clipboard -->\r
+       <wicket:fragment wicket:id="clippyPanel">\r
+               <span class="tooltipped tooltipped-n">\r
+                       <img class="ctcbtn" wicket:id="copyIcon" wicket:message="title:gb.copyToClipboard" />\r
+               </span>\r
+       </wicket:fragment>\r
        \r
 </wicket:extend>    \r
 </body>\r
index 1750b8590e660e6068067f11e71ca0febbfd0f4f..d6d188dfdf7f6664cb39806de51ba78cfec356f4 100644 (file)
@@ -102,7 +102,6 @@ import com.gitblit.wicket.panels.CommentPanel;
 import com.gitblit.wicket.panels.DiffStatPanel;\r
 import com.gitblit.wicket.panels.IconAjaxLink;\r
 import com.gitblit.wicket.panels.LinkPanel;\r
-import com.gitblit.wicket.panels.ShockWaveComponent;\r
 import com.gitblit.wicket.panels.SimpleAjaxLink;\r
 \r
 /**\r
@@ -1644,12 +1643,12 @@ public class TicketPage extends RepositoryPage {
 \r
        protected Fragment createCopyFragment(String wicketId, String text) {\r
                if (app().settings().getBoolean(Keys.web.allowFlashCopyToClipboard, true)) {\r
-                       // clippy: flash-based copy & paste\r
+                       // javascript: browser JS API based copy to clipboard\r
                        Fragment copyFragment = new Fragment(wicketId, "clippyPanel", this);\r
-                       String baseUrl = WicketUtils.getGitblitURL(getRequest());\r
-                       ShockWaveComponent clippy = new ShockWaveComponent("clippy", baseUrl + "/clippy.swf");\r
-                       clippy.setValue("flashVars", "text=" + StringUtils.encodeURL(text));\r
-                       copyFragment.add(clippy);\r
+                       ContextImage img = WicketUtils.newImage("copyIcon", "clippy.png");\r
+                       // Add the ID of the target element that holds the text to copy to clipboard\r
+                       img.add(new SimpleAttributeModifier("data-clipboard-text", text));\r
+                       copyFragment.add(img);\r
                        return copyFragment;\r
                } else {\r
                        // javascript: manual copy & paste with modal browser prompt dialog\r