overview
1 year ago
campaign_builder_controller.js
1 year ago
chart_controller.js
2 months ago
chart_interval_controller.js
2 years ago
clipboard_controller.js
1 year ago
copy_report_controller.js
2 years ago
create_report_controller.js
1 year ago
delete_data_controller.js
1 year ago
delete_report_controller.js
2 years ago
easepick_controller.js
2 years ago
examiner_controller.js
2 months ago
examiner_header_controller.js
11 months ago
export_overview_controller.js
9 months ago
export_reports_controller.js
2 years ago
filters_controller.js
6 months ago
group_controller.js
2 years ago
import_reports_controller.js
2 years ago
journey_controller.js
6 months ago
map_controller.js
9 months ago
migration_redirect_controller.js
2 years ago
modal_controller.js
2 years ago
pause_emails_controller.js
6 months ago
pie_chart_controller.js
6 months ago
plugin_group_options_controller.js
1 year ago
pruner_controller.js
5 months ago
quick_stats_controller.js
1 year ago
real_time_controller.js
6 months ago
refresh_overview_controller.js
1 year ago
rename_report_controller.js
2 years ago
report_controller.js
2 months ago
reset_analytics_controller.js
1 year ago
reset_overview_controller.js
1 year ago
save_report_controller.js
2 years ago
select_input_controller.js
2 years ago
set_favorite_report_controller.js
2 years ago
sort_controller.js
2 years ago
sortable_reports_controller.js
2 years ago
table_columns_controller.js
2 years ago
tooltip_controller.js
6 months ago
woocommerce_settings_controller.js
1 year ago
clipboard_controller.js
42 lines
| 1 | import {Controller} from "@hotwired/stimulus" |
| 2 | |
| 3 | export default class extends Controller { |
| 4 | static targets = [ |
| 5 | "statusTextElement" |
| 6 | ] |
| 7 | |
| 8 | static values = { |
| 9 | text: String |
| 10 | } |
| 11 | |
| 12 | copy(e) { |
| 13 | const statusTextElement = this.hasStatusTextElementTarget ? this.statusTextElementTarget : this.element |
| 14 | const initialText = statusTextElement.innerHTML |
| 15 | const textToCopy = this.textValue |
| 16 | |
| 17 | this.copyTextToClipboard(textToCopy) |
| 18 | statusTextElement.innerHTML = iawpText.copied |
| 19 | setTimeout(() => { |
| 20 | statusTextElement.innerHTML = initialText |
| 21 | }, 1000) |
| 22 | } |
| 23 | |
| 24 | copyTextToClipboard(text) { |
| 25 | if (navigator.clipboard && window.isSecureContext) { |
| 26 | navigator.clipboard.writeText(text) |
| 27 | } else { |
| 28 | const textArea = document.createElement("textarea") |
| 29 | textArea.value = text |
| 30 | textArea.style.position = "fixed" |
| 31 | textArea.style.left = "-999999px" |
| 32 | textArea.style.top = "-999999px" |
| 33 | document.body.appendChild(textArea) |
| 34 | textArea.focus() |
| 35 | textArea.select() |
| 36 | return new Promise((res, rej) => { |
| 37 | document.execCommand('copy') ? res() : rej() |
| 38 | textArea.remove() |
| 39 | }) |
| 40 | } |
| 41 | } |
| 42 | } |