| @@ -1,9 +1,5 @@ | ||
| 1 | 1 | jQuery(document).ready(function ($) { |
| 2 | - //Export page | |
| 3 | - //$('#bulk-action-selector-top option[value="exportsnp"]').css('color', '#999').prop('disabled', true); | |
| 4 | - | |
| 5 | - // | |
| 6 | 2 | $("a#winp-snippet-status-switch").on('click', function (e) { |
| 7 | 3 | e.preventDefault(); |
| 8 | 4 | var href = $(this); |
| 9 | 5 | href.addClass('winp-snippet-switch-loader'); |
| @@ -52,8 +48,81 @@ | ||
| 52 | 48 | |
| 53 | 49 | $("input.wbcr_inp_input_priority").on('keydown', stop_enter); |
| 54 | 50 | $("input.wbcr_inp_input_priority").on('keyup', stop_enter); |
| 55 | 51 | $("input.wbcr_inp_input_priority").on('keypress', stop_enter); |
| 52 | + | |
| 53 | + // Handle click on shortcode input to copy to clipboard | |
| 54 | + $("input.wbcr_inp_shortcode_input").on('click', function (e) { | |
| 55 | + var input = $(this); | |
| 56 | + var value = input.val(); | |
| 57 | + | |
| 58 | + // Select the text | |
| 59 | + this.setSelectionRange(0, this.value.length); | |
| 60 | + | |
| 61 | + // Copy to clipboard | |
| 62 | + if (navigator.clipboard && navigator.clipboard.writeText) { | |
| 63 | + // Modern clipboard API | |
| 64 | + navigator.clipboard.writeText(value).then(function() { | |
| 65 | + showCopyNotice(input); | |
| 66 | + }).catch(function(err) { | |
| 67 | + console.error('Failed to copy:', err); | |
| 68 | + fallbackCopy(input); | |
| 69 | + }); | |
| 70 | + } else { | |
| 71 | + // Fallback for older browsers | |
| 72 | + fallbackCopy(input); | |
| 73 | + } | |
| 74 | + }); | |
| 75 | + | |
| 76 | + function fallbackCopy(input) { | |
| 77 | + try { | |
| 78 | + input[0].select(); | |
| 79 | + var successful = document.execCommand('copy'); | |
| 80 | + if (successful) { | |
| 81 | + showCopyNotice(input); | |
| 82 | + } | |
| 83 | + } catch (err) { | |
| 84 | + console.error('Failed to copy:', err); | |
| 85 | + } | |
| 86 | + } | |
| 87 | + | |
| 88 | + function showCopyNotice(input) { | |
| 89 | + // Remove any existing notices | |
| 90 | + $('.winp-copy-notice').remove(); | |
| 91 | + | |
| 92 | + // Create and show notice | |
| 93 | + var notice = $('<div class="winp-copy-notice"><span>Copied to clipboard!</span></div>'); | |
| 94 | + input.after(notice); | |
| 95 | + | |
| 96 | + // Position the notice | |
| 97 | + notice.css({ | |
| 98 | + position: 'absolute', | |
| 99 | + background: '#6366f1', | |
| 100 | + color: '#fff', | |
| 101 | + borderRadius: '3px', | |
| 102 | + fontSize: '12px', | |
| 103 | + zIndex: 1000, | |
| 104 | + whiteSpace: 'nowrap', | |
| 105 | + boxShadow: '0 2px 5px rgba(0,0,0,0.2)', | |
| 106 | + height: '100%', | |
| 107 | + width: '100%' | |
| 108 | + }); | |
| 109 | + | |
| 110 | + // Style the span | |
| 111 | + notice.find('span').css({ | |
| 112 | + display: 'flex', | |
| 113 | + justifyContent: 'center', | |
| 114 | + alignItems: 'center', | |
| 115 | + height: '100%' | |
| 116 | + }); | |
| 117 | + | |
| 118 | + // Fade out and remove after 2 seconds | |
| 119 | + setTimeout(function() { | |
| 120 | + notice.fadeOut(300, function() { | |
| 121 | + notice.remove(); | |
| 122 | + }); | |
| 123 | + }, 2000); | |
| 124 | + } | |
| 56 | 125 | }); |
| 57 | 126 | |
| 58 | 127 | function stop_enter(e) { |
| 59 | 128 | if (e.keyCode === 13) { |