Skip to content

Commit

Permalink
Fixes #37676 - Refactor deprecated jquery functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAga committed Aug 15, 2024
1 parent 306acad commit 7bcb26f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
function virt_who_copy_configuration_to_clipboard(text) {
var aux = document.createElement("textarea");
$(aux).html(text);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
try {
navigator.clipboard.writeText(text);
} catch (error) {
console.error(
"Copying to clipboard is not supported in this browser, or in unsecure connection."
);
console.error(error);
}
}
12 changes: 9 additions & 3 deletions app/assets/javascripts/foreman_virt_who_configure/config_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ $(document).ready(function () {
virt_who_update_hypervisor_fields();
virt_who_update_ahv_debug();

$('#foreman_virt_who_configure_config_listing_mode').change(virt_who_update_listing_mode);
$('#foreman_virt_who_configure_config_hypervisor_type').change(virt_who_update_credentials_help);
$('#foreman_virt_who_configure_config_hypervisor_type').change(virt_who_update_hypervisor_fields);
$("#foreman_virt_who_configure_config_listing_mode").on("change", virt_who_update_listing_mode);
$("#foreman_virt_who_configure_config_hypervisor_type").on(
"change",
virt_who_update_credentials_help
);
$("#foreman_virt_who_configure_config_hypervisor_type").on(
"change",
virt_who_update_hypervisor_fields
);
});
4 changes: 2 additions & 2 deletions app/views/foreman_virt_who_configure/configs/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</div>
<div class="col-md-8">
<div class="terminal-buttons">
<%= link_to _('Copy to clipboard'), nil, :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_command").html()); return false' %>
<%= link_to _('Copy to clipboard'), '#', :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_command").html()); return false' %>
</div>
</div>
</div>
Expand All @@ -103,7 +103,7 @@
</div>
<div class="col-md-8">
<div class="terminal-buttons">
<%= link_to _('Copy to clipboard'), nil, :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_script").html()); return false' %>
<%= link_to _('Copy to clipboard'), '#', :class => 'btn btn-default', :onclick => 'virt_who_copy_configuration_to_clipboard($("#config_script").html()); return false' %>
<%= link_to _('Download the script'), deploy_script_foreman_virt_who_configure_config_path(@config), :class => 'btn btn-default' %>
</div>
</div>
Expand Down

0 comments on commit 7bcb26f

Please sign in to comment.