PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.74
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.74
9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 8.5.4 All 221 releases
wpvr / admin / js / wpvr-shortcode.js

wpvr-shortcode.js in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 8.5.74, at admin/js/wpvr-shortcode.js

63 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1
2 jQuery(document).ready(function () {
3 document.getElementById("wpvr-copy-shortcode").addEventListener("click", function() {
4 copyToClipboard(document.getElementById("copy-shortcode"));
5 });
6
7 function copyToClipboard(elem) {
8 // create hidden text element, if it doesn\'t already exist
9 var targetId = "_hiddenCopyText_";
10 var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA";
11 var origSelectionStart, origSelectionEnd;
12 if (isInput) {
13 // can just use the original source element for the selection and copy
14 target = elem;
15 origSelectionStart = elem.selectionStart;
16 origSelectionEnd = elem.selectionEnd;
17 } else {
18 // must use a temporary form element for the selection and copy
19 target = document.getElementById(targetId);
20 if (!target) {
21 var target = document.createElement("textarea");
22 target.style.position = "absolute";
23 target.style.left = "-9999px";
24 target.style.top = "0";
25 target.id = targetId;
26 document.body.appendChild(target);
27 }
28 target.textContent = elem.textContent;
29 }
30 // select the content
31 var currentFocus = document.activeElement;
32 target.focus();
33 target.setSelectionRange(0, target.value.length);
34
35 // copy the selection
36 var succeed;
37 try {
38 succeed = document.execCommand("copy");
39 document.getElementById("wpvr-copied-notice").innerHTML = "Copied!";
40 } catch(e) {
41 succeed = false;
42 }
43 // restore original focus
44 if (currentFocus && typeof currentFocus.focus === "function") {
45 currentFocus.focus();
46 }
47
48 setTimeout(function(){
49 document.getElementById("wpvr-copied-notice").innerHTML = "";
50 }, 2000 );
51
52 if (isInput) {
53 // restore prior selection
54 elem.setSelectionRange(origSelectionStart, origSelectionEnd);
55 } else {
56 // clear temporary content
57 target.textContent = "";
58 }
59 document.getElementById("wpvr-copy-shortcode").scrollIntoView()
60 return succeed;
61 };
62 });
63