PluginProbe
Text Typing – grab attention with animated typing headlines / trunk
Text Typing – grab attention with animated typing headlines vtrunk
2.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8
text-typing / dashboard / post.js

post.js in Text Typing – grab attention with animated typing headlines trunk, at dashboard/post.js

116 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 window.copyBPlAdminShortcode = function (postID) {
2 // Get the input element by ID
3 var copyText = document.querySelector('#bPlAdminShortcode-' + postID + ' input');
4
5 // Select the text field
6 copyText.select();
7 copyText.setSelectionRange(0, 99999); // For mobile devices
8
9 // Copy the text inside the text field
10 document.execCommand("copy");
11
12 // Optional: Provide feedback to the user, e.g., change the tooltip text
13 var tooltip = document.querySelector('#bPlAdminShortcode-' + postID + ' .tooltip');
14 tooltip.innerHTML = "Copied Successfully!";
15 }
16
17
18
19 // document.addEventListener('DOMContentLoaded', () => {
20 // const copyBtn = document.getElementById('ttbCopyBtn');
21 // const input = document.getElementById('ttbShortcodeInput');
22 // const message = document.getElementById('ttbCopyMessage');
23
24 // if (copyBtn && input) {
25 // copyBtn.addEventListener('click', async () => {
26 // const shortcode = input.value;
27
28 // if (navigator.clipboard && navigator.clipboard.writeText) {
29 // try {
30 // await navigator.clipboard.writeText(shortcode);
31 // showCopiedMessage();
32 // } catch (err) {
33 // console.warn('Clipboard API failed, trying fallback...', err);
34 // fallbackCopy(shortcode);
35 // }
36 // } else {
37 // fallbackCopy(shortcode);
38 // }
39 // });
40 // }
41
42 // function fallbackCopy(text) {
43 // const temp = document.createElement('textarea');
44 // temp.value = text;
45 // document.body.appendChild(temp);
46 // temp.select();
47 // temp.setSelectionRange(0, 99999);
48 // try {
49 // document.execCommand('copy');
50 // showCopiedMessage();
51 // } catch (err) {
52 // console.error('Fallback copy failed:', err);
53 // alert('Copy failed. Please copy manually.');
54 // }
55 // document.body.removeChild(temp);
56 // }
57
58 // function showCopiedMessage() {
59 // message.style.display = 'block';
60 // setTimeout(() => (message.style.display = 'none'), 2000);
61 // }
62 // });
63
64
65 document.addEventListener('DOMContentLoaded', () => {
66 const copyBtn = document.getElementById('ttbCopyBtn');
67 const input = document.getElementById('ttbShortcodeInput');
68
69 if (copyBtn && input) {
70 copyBtn.addEventListener('click', async () => {
71 const shortcode = input.value;
72
73 // Try modern Clipboard API
74 if (navigator.clipboard && navigator.clipboard.writeText) {
75 try {
76 await navigator.clipboard.writeText(shortcode);
77 showCopiedMessage();
78 return;
79 } catch (err) {
80 // console.warn('Clipboard API failed, using fallback.', err);
81 fallbackCopy(shortcode);
82 }
83 } else {
84 fallbackCopy(shortcode);
85 }
86 });
87 }
88
89 function fallbackCopy(text) {
90 const temp = document.createElement('textarea');
91 temp.value = text;
92 document.body.appendChild(temp);
93 temp.select();
94 temp.setSelectionRange(0, 99999);
95 try {
96 document.execCommand('copy');
97 showCopiedMessage();
98 } catch (err) {
99 // console.error('Fallback copy failed:', err);
100 alert('Copy failed. Please copy manually.');
101 }
102 document.body.removeChild(temp);
103 }
104
105 function showCopiedMessage() {
106 const originalText = copyBtn.textContent;
107 copyBtn.textContent = '�
108 Successfully Copied!';
109 copyBtn.disabled = true;
110 setTimeout(() => {
111 copyBtn.textContent = originalText;
112 copyBtn.disabled = false;
113 }, 2000);
114 }
115 });
116