diff --git a/app/assets/javascripts/katello/common/chosen.jquery.js b/app/assets/javascripts/katello/common/chosen.jquery.js index f699c80a803..7fb1b43de9d 100644 --- a/app/assets/javascripts/katello/common/chosen.jquery.js +++ b/app/assets/javascripts/katello/common/chosen.jquery.js @@ -342,7 +342,7 @@ this.search_results.mouseout(__bind(function(evt) { return this.search_results_mouseout(evt); }, this)); - this.form_field_jq.bind("liszt:updated", __bind(function(evt) { + this.form_field_jq.on("liszt:updated", __bind(function(evt) { return this.results_update_field(evt); }, this)); this.search_field.blur(__bind(function(evt) { @@ -358,7 +358,7 @@ this.search_choices.click(__bind(function(evt) { return this.choices_click(evt); }, this)); - return this.search_field.focus(__bind(function(evt) { + return this.search_field.on("focus", __bind(function(evt) { return this.input_focus(evt); }, this)); } @@ -376,7 +376,7 @@ this.container.removeClass('chzn-disabled'); this.search_field.attr('disabled', false); if (!this.is_multiple) { - return this.selected_item.bind("focus", this.activate_action); + return this.selected_item.on("focus", this.activate_action); } } }; diff --git a/app/assets/javascripts/katello/common/env_select_scroll.js b/app/assets/javascripts/katello/common/env_select_scroll.js index ece59373682..92d49a5b39d 100644 --- a/app/assets/javascripts/katello/common/env_select_scroll.js +++ b/app/assets/javascripts/katello/common/env_select_scroll.js @@ -20,7 +20,7 @@ KT.env_select_scroll = function(options) { combined_width = 0, anchors = trail.find("a, label"), my_min_size_selected = min_size_selected; - anchors.unbind("mouseout").unbind("mouseover").width('auto'); + anchors.off("mouseout").off("mouseover").width('auto'); anchors.each(function() { combined_width += $(this).width() + anchor_padding; @@ -86,7 +86,7 @@ KT.env_select_scroll = function(options) { }; - anchor.mouseover(function() { + anchor.on("mouseover", function() { if (over_interval) { return false; } @@ -105,7 +105,7 @@ KT.env_select_scroll = function(options) { }, freq); }); - anchor.mouseout(function() { + anchor.on("mouseout", function() { if (out_interval) { return false; } diff --git a/app/assets/javascripts/katello/common/katello.js b/app/assets/javascripts/katello/common/katello.js index 53de8e262f0..aa6574dd47b 100644 --- a/app/assets/javascripts/katello/common/katello.js +++ b/app/assets/javascripts/katello/common/katello.js @@ -9,7 +9,7 @@ KT.widget = {}; // Must be at the top to prevent AngularJS unnecessary digest operations // And to handle the hashPrefix that AngularJS adds that confuses BBQ -$(window).bind("hashchange", function(event) { +$(window).on("hashchange", function(event) { // refresh the favicon to make sure it shows up $('link[type*=icon]').detach().appendTo('head'); }); @@ -31,7 +31,7 @@ function update_status() { } }, error: function (xhr, status, error) { - statusElement.text(jQuery.parseJSON(xhr.responseText).message); + statusElement.text(JSON.parse(xhr.responseText).message); clearInterval(i); } }); @@ -212,14 +212,14 @@ var client_common = { /** * Document Ready function */ -$(document).ready(function (){ +$(document).on('loadJS', function (){ KT.common.link_hover_setup('dark'); //Add a handler so that if any input has focus // our keyboard shortcuts don't steal it - $(":input").focus(function() { + $(":input").on("focus", function() { onInputField = true; - }).blur(function() { + }).on("blur", function() { onInputField = false; }); @@ -231,13 +231,14 @@ $(document).ready(function (){ /** * Window Ready function */ + $(window).ready(function(){ $('.fc').parent().css({"text-align":"center"}); //all purpose display loading icon for ajax calls - $("#loading").bind("ajaxSend", function(){ + $("#loading").on("ajaxSend", function(){ $(this).show(); $('body').css('cursor', 'wait'); - }).bind("ajaxComplete", function(){ + }).on("ajaxComplete", function(){ $(this).hide(); $('body').css('cursor', 'default'); }); diff --git a/app/assets/javascripts/katello/common/katello_object.js b/app/assets/javascripts/katello/common/katello_object.js index b6fb76ccb62..be56ba7ca54 100644 --- a/app/assets/javascripts/katello/common/katello_object.js +++ b/app/assets/javascripts/katello/common/katello_object.js @@ -17,9 +17,9 @@ KT.object.label = (function(){ disable_inputs(undefined); - $('.create_button').mousedown(function() {retrieve_label = false;}); + $('.create_button').on("mousedown", function() {retrieve_label = false;}); - $('.name_input').blur(function(event){ + $('.name_input').on("blur", function(event){ var name_input = $(this), name = name_input.val(), label = $(this).closest('fieldset').next('fieldset'), @@ -51,7 +51,7 @@ KT.object.label = (function(){ enable_inputs(name_input); } }); - $('.name_input').bind('click, focusin', function() { + $('.name_input').on('click, focusin', function() { disable_inputs($(this)); initial_name_value = $(this).val(); }); diff --git a/app/assets/javascripts/katello/common/menu.js b/app/assets/javascripts/katello/common/menu.js index 1c313ac08ed..be5db8f7cfd 100644 --- a/app/assets/javascripts/katello/common/menu.js +++ b/app/assets/javascripts/katello/common/menu.js @@ -8,7 +8,7 @@ /** * Document Ready function */ -$(document).ready(function (){ +$(document).on('loadJS', function (){ KT.menu.menuSetup(); }); @@ -60,19 +60,19 @@ KT.menu = (function(){ var currentSubnav = subnav.find('.' + tabType + '.second_level').parent(); var enter = function(){topLevelTab.trigger("mouseenter");}; var leave = function(){topLevelTab.delay("800").trigger("mouseout")}; - currentSubnav.hover(function(){enter()},function(){leave()}); + currentSubnav.on('mouseenter', enter).on('mouseleave', leave); - topLevelTab.bind("open", function(){ + topLevelTab.on("open", function(){ //make the tab "highlight" on hover $(this).addClass('selected'); activeSubnav.hide(); //show the current subnav and trigger it to stay open currentSubnav.slideDown('fast'); topLevelTab.trigger("hovering"); - }).bind("hovering", function(){ + }).on("hovering", function(){ currentSubnav.show(); }) - .bind("close.menu", function(){ + .on("close.menu", function(){ //take away tab highlight if(!$(this).hasClass('active')) { $(this).removeClass('selected'); @@ -100,13 +100,13 @@ KT.menu = (function(){ li.hoverIntent( function(){ - $(document).mouseup(); + $(document).trigger("mouseup"); ul.addClass("third_level").slideDown('fast'); }, function(){ ul.slideUp('fast').removeClass("third_level"); }); - li.mouseenter().mouseleave(); + li.trigger("mouseenter").trigger("mouseleave"); } }; })(); diff --git a/app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js b/app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js index a1a223b0de4..ebcb543734a 100644 --- a/app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js +++ b/app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js @@ -6,8 +6,8 @@ $(document).on('ContentLoad', function(){ window.tfm.hosts.registerPluginAttributes("os", ['lifecycle_environment_id', 'content_view_id', 'environment_id', 'content_source_id', 'architecture_id', 'parent_id']); - $("#hostgroup_lifecycle_environment_id").change(KT.hosts.environmentChanged); - $("#host_lifecycle_environment_id").change(KT.hosts.environmentChanged); + $("#hostgroup_lifecycle_environment_id").on("change",KT.hosts.environmentChanged); + $("#host_lifecycle_environment_id").on("change", KT.hosts.environmentChanged); KT.hosts.update_media_enablement(); KT.hosts.set_media_selection_bindings(); @@ -266,10 +266,10 @@ KT.hosts.on_synced_content_dropdown_change = function() { KT.hosts.set_install_media_bindings = function() { // reset the host medium id - $("#host_medium_id").change(KT.hosts.on_install_media_dropdown_change); - $("#s2id_host_medium_id").change(KT.hosts.on_install_media_dropdown_change); - $("#hostgroup_medium_id").change(KT.hosts.on_install_media_dropdown_change); - $("#s2id_hostgroup_medium_id").change(KT.hosts.on_install_media_dropdown_change); + $("#host_medium_id").on("change", KT.hosts.on_install_media_dropdown_change); + $("#s2id_host_medium_id").on("change", KT.hosts.on_install_media_dropdown_change); + $("#hostgroup_medium_id").on("change", KT.hosts.on_install_media_dropdown_change); + $("#s2id_hostgroup_medium_id").on("change", KT.hosts.on_install_media_dropdown_change); }; KT.hosts.set_synced_content_bindings = function() { diff --git a/app/assets/javascripts/katello/organizations/download_certificate.js b/app/assets/javascripts/katello/organizations/download_certificate.js index f1873d4c20b..63e3ec3f658 100644 --- a/app/assets/javascripts/katello/organizations/download_certificate.js +++ b/app/assets/javascripts/katello/organizations/download_certificate.js @@ -1,4 +1,4 @@ -$(document).ready(function() { +$(document).on('loadJS', function() { $('body').on('click', '#download_debug_cert_key', function(e) { e.preventDefault(); window.location.href = $("#download_debug_cert_key").data("url"); diff --git a/app/assets/javascripts/katello/sync_management/sync_management.js b/app/assets/javascripts/katello/sync_management/sync_management.js index 492282c18fc..cc0b706e2d6 100644 --- a/app/assets/javascripts/katello/sync_management/sync_management.js +++ b/app/assets/javascripts/katello/sync_management/sync_management.js @@ -356,21 +356,21 @@ $.each(KT.repo_status, function (repo_id, status) { KT.content.reset_products(KT.repo_status); KT.content_actions.addSyncing(ids); -$("#select_all").click(KT.content.select_all); -$("#select_none").click(KT.content.select_none); -$("#collapse_all").click(KT.content.collapse_all); -$("#expand_all").click(KT.content.expand_all); +$("#select_all").on("click", KT.content.select_all); +$("#select_none").on("click", KT.content.select_none); +$("#collapse_all").on("click", KT.content.collapse_all); +$("#expand_all").on("click", KT.content.expand_all); KT.content.showAll(); KT.content.select_repo(); -$("#products_table").delegate(".cancel_sync", "click", function () { +$("#products_table").on("click", ".cancel_sync", function () { var repo_id = $(this).parents("tr").attr("data-id"); KT.content_actions.cancelSync(repo_id, $(this)); }); $("#sync_product_form") - .bind("ajax:success", function (evt, data, status, xhr) { + .on("ajax:success", function (evt, data, status, xhr) { var ids = []; $.each(data, function (index, item) { ids.push(item.id); @@ -379,13 +379,13 @@ $("#sync_product_form") }); KT.content_actions.addSyncing(ids); }) - .bind("ajax:beforeSend", function (evt, data, status, xhr) { + .on("ajax:beforeSend", function (evt, data, status, xhr) { if ($("input[name='repoids[]']:checked").length === 0) { return false; } }); -$("#sync_toggle").change(function () { +$("#sync_toggle").on("change", function () { var img = ""; $("#sync_toggle_cont").append(img); if ($(this).is(":checked")) { @@ -397,5 +397,5 @@ $("#sync_toggle").change(function () { }); $.each($("input[name='repoids[]']"), function (index, checkbox) { - $(checkbox).click(KT.content.select_repo); + $(checkbox).on("click", KT.content.select_repo); }); diff --git a/app/assets/javascripts/katello/widgets/env_content_view_selector.js b/app/assets/javascripts/katello/widgets/env_content_view_selector.js index 62c1f8cda69..44f4f4c0c78 100644 --- a/app/assets/javascripts/katello/widgets/env_content_view_selector.js +++ b/app/assets/javascripts/katello/widgets/env_content_view_selector.js @@ -20,13 +20,13 @@ KT.env_content_view_selector = (function() { saved_content_view_id = current_content_view_id; env_select = KT.path_select(env_div_id, name, envs, {select_mode:'single', inline: true}); - $(document).unbind(env_select.get_select_event()); + $(document).off(env_select.get_select_event()); // select the current environment env_select.select(current_env_id); // if the user changes the environment, update the available content views - $(document).bind(env_select.get_select_event(), function(event) { + $(document).on(env_select.get_select_event(), function(event) { update_content_views(KT.utils.keys(env_select.get_selected())); enable_buttons(); }); @@ -34,7 +34,7 @@ KT.env_content_view_selector = (function() { // render the content view selector and the save/cancel buttons render_selector(content_view_div, selector_buttons_div, content_views, current_content_view_id); - $('#content_view_select').unbind('change').change(function() { + $('#content_view_select').off('change').on("change", function() { enable_buttons(); }); disable_buttons(); @@ -44,7 +44,7 @@ KT.env_content_view_selector = (function() { }, register_cancel = function() { var cancel_button = $('.cancel_env_content_view'); - cancel_button.unbind('click').click(function(e) { + cancel_button.off('click').on("click", function(e) { var current_env = KT.utils.values(env_select.get_selected()); if ((current_env.length === 0) || (current_env[0]['id'] !== saved_env_id)) { @@ -60,7 +60,7 @@ KT.env_content_view_selector = (function() { }, register_save = function() { var save_button = $('.save_env_content_view'); - save_button.unbind('click').click(function(e) { + save_button.off('click').on("click", function(e) { e.preventDefault(); disable_buttons(); diff --git a/app/assets/javascripts/katello/widgets/path_selector.js b/app/assets/javascripts/katello/widgets/path_selector.js index 3ebf52c04e3..f4bd89ad7c5 100644 --- a/app/assets/javascripts/katello/widgets/path_selector.js +++ b/app/assets/javascripts/katello/widgets/path_selector.js @@ -52,7 +52,7 @@ KT.path_select = function(div_id, name, environments, options_in){ } if(options.submit_button_text){ - path_selector.find('.KT_path_select_submit_button').click(function(e){ + path_selector.find('.KT_path_select_submit_button').on("click", function(e){ if(!options.inline) { path_selector.hide(); } @@ -61,7 +61,7 @@ KT.path_select = function(div_id, name, environments, options_in){ } if(options.cancel_button_text){ - path_selector.find('.KT_path_select_cancel_button').click(function(e){ + path_selector.find('.KT_path_select_cancel_button').on("click", function(e){ clear_selected(); if(!options.inline) { path_selector.hide(); @@ -77,7 +77,7 @@ KT.path_select = function(div_id, name, environments, options_in){ path_selector.hide(); if(options.activate_on_click) { - div.click(function(e) { path_selector.show(); }); + div.on("click", function(e) { path_selector.show(); }); } else { div.hoverIntent({ over:function(){ path_selector.show(); }, @@ -96,7 +96,7 @@ KT.path_select = function(div_id, name, environments, options_in){ disable_all(); } - $(document).mouseup(function(e){ + $(document).on("mouseup", function(e){ if(path_selector.has(e.target).length === 0 && !options.inline) { path_selector.hide(); } @@ -259,11 +259,11 @@ KT.path_select = function(div_id, name, environments, options_in){ } if(!options.inline){ path_selector.show(); - scroll_obj.bind('#' + KT.common.escapeId(paths_id)); + scroll_obj.on('#' + KT.common.escapeId(paths_id)); path_selector.hide(); } else { - scroll_obj.bind('#' + KT.common.escapeId(paths_id)); + scroll_obj.on('#' + KT.common.escapeId(paths_id)); } }, get_submit_event = function(){ diff --git a/app/assets/javascripts/katello/widgets/subpanel_new.js b/app/assets/javascripts/katello/widgets/subpanel_new.js index 4c6e48ef83b..fa4c35caaa3 100644 --- a/app/assets/javascripts/katello/widgets/subpanel_new.js +++ b/app/assets/javascripts/katello/widgets/subpanel_new.js @@ -1,4 +1,4 @@ -$(document).ready(function(){ +$(document).on('loadJS', function(){ var form_id = $('#new_subpanel'), form_submit_id = form_id.find('.subpanel_create'), url_after_submit = form_submit_id.data('url_after_submit'); diff --git a/app/views/katello/sync_management/index.html.erb b/app/views/katello/sync_management/index.html.erb index 257bd37f356..fcc49800c8f 100644 --- a/app/views/katello/sync_management/index.html.erb +++ b/app/views/katello/sync_management/index.html.erb @@ -9,7 +9,7 @@ "no_start_time": "<%= escape_javascript(_('No start time currently available.')) %>" }); - KT.repo_status = $.parseJSON('<%= escape_javascript(@repo_status.to_json.html_safe) %>'); + KT.repo_status = JSON.parse('<%= escape_javascript(@repo_status.to_json.html_safe) %>'); KT.permissions = { "syncable" : <%= any_syncable? %> }; <% end -%> diff --git a/vendor/assets/javascripts/katello/chosen.jquery.js b/vendor/assets/javascripts/katello/chosen.jquery.js index 8b28bc045fa..684a627c337 100644 --- a/vendor/assets/javascripts/katello/chosen.jquery.js +++ b/vendor/assets/javascripts/katello/chosen.jquery.js @@ -382,7 +382,7 @@ Copyright (c) 2011 by Harvest this.search_results.mouseout(function(evt) { return _this.search_results_mouseout(evt); }); - this.form_field_jq.bind("liszt:updated", function(evt) { + this.form_field_jq.on("liszt:updated", function(evt) { return _this.results_update_field(evt); }); this.search_field.blur(function(evt) { @@ -421,7 +421,7 @@ Copyright (c) 2011 by Harvest this.container.removeClass('chzn-disabled'); this.search_field[0].disabled = false; if (!this.is_multiple) { - return this.selected_item.bind("focus", this.activate_action); + return this.selected_item.on("focus", this.activate_action); } } }; diff --git a/vendor/assets/javascripts/katello/jquery.ba-bbq.js b/vendor/assets/javascripts/katello/jquery.ba-bbq.js index f251123acd7..c0cd01e262d 100644 --- a/vendor/assets/javascripts/katello/jquery.ba-bbq.js +++ b/vendor/assets/javascripts/katello/jquery.ba-bbq.js @@ -1021,7 +1021,7 @@ // example) use $(window).trigger( 'hashchange' ); // * The event can be bound before DOM ready, but since it won't be usable // before then in IE6/7 (due to the necessary Iframe), recommended usage is - // to bind it inside a $(document).ready() callback. + // to bind it inside a $(document).on('loadJS', ) callback. jq_event_special[ str_hashchange ] = $.extend( jq_event_special[ str_hashchange ], { diff --git a/vendor/assets/javascripts/katello/jquery.hoverIntent.js b/vendor/assets/javascripts/katello/jquery.hoverIntent.js index 3dcff261f60..d84732ecb56 100644 --- a/vendor/assets/javascripts/katello/jquery.hoverIntent.js +++ b/vendor/assets/javascripts/katello/jquery.hoverIntent.js @@ -87,7 +87,7 @@ // set "previous" X and Y position based on initial entry point pX = ev.pageX; pY = ev.pageY; // update "current" X and Y position based on mousemove - $(ob).bind("mousemove",track); + $(ob).on("mousemove",track); // start polling interval (self-calling timeout) to compare mouse coordinates over time if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );} @@ -101,6 +101,6 @@ }; // bind the function to the two event listeners - return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover); + return this.on('mouseenter',handleHover).on('mouseleave',handleHover); }; })(jQuery); \ No newline at end of file diff --git a/webpack/scenes/Hosts/ChangeContentSource/helpers.js b/webpack/scenes/Hosts/ChangeContentSource/helpers.js index 738b6f5f0a4..4fe1db5d4d9 100644 --- a/webpack/scenes/Hosts/ChangeContentSource/helpers.js +++ b/webpack/scenes/Hosts/ChangeContentSource/helpers.js @@ -18,12 +18,6 @@ export const formIsLoading = (data, contentView, change) => ( change === STATUS.PENDING ); -export const copyToClipboard = (event, textToCopy) => { - const clipboard = event.currentTarget.parentElement; - const el = document.createElement('textarea'); - el.value = textToCopy; - clipboard.appendChild(el); - el.select(); - document.execCommand('copy'); - clipboard.removeChild(el); +export const copyToClipboard = async (event, textToCopy) => { + await navigator.clipboard.writeText(textToCopy); };