Skip to content

Commit

Permalink
Fixes #37671 - Refactor deprecated jquery functions (Katello#11086)
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAga authored Aug 28, 2024
1 parent 22ed429 commit 50ff909
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 65 deletions.
6 changes: 3 additions & 3 deletions app/assets/javascripts/katello/common/chosen.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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));
}
Expand All @@ -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);
}
}
};
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/katello/common/env_select_scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,7 +86,7 @@ KT.env_select_scroll = function(options) {
};


anchor.mouseover(function() {
anchor.on("mouseover", function() {
if (over_interval) {
return false;
}
Expand All @@ -105,7 +105,7 @@ KT.env_select_scroll = function(options) {
}, freq);
});

anchor.mouseout(function() {
anchor.on("mouseout", function() {
if (out_interval) {
return false;
}
Expand Down
15 changes: 8 additions & 7 deletions app/assets/javascripts/katello/common/katello.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand All @@ -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);
}
});
Expand Down Expand Up @@ -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;
});

Expand All @@ -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');
});
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/katello/common/katello_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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();
});
Expand Down
14 changes: 7 additions & 7 deletions app/assets/javascripts/katello/common/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Document Ready function
*/
$(document).ready(function (){
$(document).on('loadJS', function (){
KT.menu.menuSetup();
});

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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");
}
};
})();
12 changes: 6 additions & 6 deletions app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 = "<img src='" + KT.common.spinner_path() + "'>";
$("#sync_toggle_cont").append(img);
if ($(this).is(":checked")) {
Expand All @@ -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);
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ 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();
});

// 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();
Expand All @@ -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)) {
Expand All @@ -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();

Expand Down
12 changes: 6 additions & 6 deletions app/assets/javascripts/katello/widgets/path_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
Expand All @@ -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(); },
Expand All @@ -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();
}
Expand Down Expand Up @@ -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(){
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/katello/widgets/subpanel_new.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion app/views/katello/sync_management/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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? %> };
</script>
<% end -%>
Expand Down
4 changes: 2 additions & 2 deletions vendor/assets/javascripts/katello/chosen.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion vendor/assets/javascripts/katello/jquery.ba-bbq.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ], {

Expand Down
Loading

0 comments on commit 50ff909

Please sign in to comment.