Commit 3d1abcc2 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Robert Lyon
Browse files

Bug 1741987: Update jquery - Events

Event
   Breaking change: .load(), .unload(), and .error() removed
   Breaking change: .on("ready", fn) removed
   Breaking change: event.pageX and event.pageY normalization removed
   Breaking change: jQuery.event.props and jQuery.event.fixHooks removed
   Breaking change: Delegated events with bad selectors throw immediately
   Deprecated: .bind() and .delegate()
     no calls to .bind() for events in core.
     Only calls to bind() refer to the js bind of arguments to functions.
     no calls to unbind() for event in core.
     Only calls to unbind refer to the unbind method defined in
     formChangeManager not related to the jQuery method.

    Warnings fix
    JQMIGRATE: jQuery.fn.click() event shorthand is deprecated
    - also applies to the other event shorthands, including:
     blur, focus, focusin, focusout, resize, scroll, dblclick, mousedown,
     mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave,
     change, select, submit, keydown, keypress, keyup, and contextmenu.

    JQMIGRATE: jQuery.fn.hover() is deprecated
    JQMIGRATE: jQuery(window).on('load'...) called after load event occurred
	(for FileBrowser we can see this error when editing a block in a page)

behatnotneeded

Change-Id: I1a50050f882b864ad63d273de160e0b441a77705
parent 0dad0592
......@@ -27,7 +27,7 @@ $form = privacy_form(!get_config('institutionstrictprivacy'), !get_config('insti
// JQuery logic for panel hide/show submit button.
$js = <<< EOF
$( document ).ready(function() {
$(".state-label").click(function() {
$(".state-label").on("click", function() {
$(this).siblings( ".switch-inner" ).toggleClass("redraw-consent");
showSubmitButton();
});
......
......@@ -250,7 +250,7 @@ function process_allowed_iframe_url($url) {
$js = <<<EOF
jQuery(function($) {
$('.url-open-editform').click(function(e) {
$('.url-open-editform').on("click", function(e) {
e.preventDefault();
$('#' + this.id).addClass('collapse-indicator');
$('#' + this.id).toggleClass('open');
......
......@@ -87,7 +87,7 @@ jQuery(function($) {
$('#menuitemlist').empty().append(form);
if (data.focusid) {
$('#item' + data.focusid).focus();
$('#item' + data.focusid).trigger("focus");
}
}
......@@ -166,7 +166,7 @@ jQuery(function($) {
// A text field for the name
var label = $('<label>', {'for':'name'+item.id,'class':'accessible-hidden'}).text(item.label);
var name = $('<input>', {'type':'text','class':'text form-control input-sm','id':'name'+item.id,'value':item.name});
name.keydown(function(e) {
name.on('keydown', function(e) {
if (e.keyCode == 13) {
save.trigger('click');
e.preventDefault();
......@@ -199,7 +199,7 @@ jQuery(function($) {
menuitem.addClass('hidden');
var newrow = editform(item);
newrow.insertBefore(menuitem)
$('#name' + item.id).focus();
$('#name' + item.id).trigger("focus");
}
// Receive standard json error message
......
......@@ -141,12 +141,12 @@ $form = pieform(array(
$inlinejs = <<<EOF
jQuery(function($) {
$('#addfontform_fontfileZip').change(function() {
$('#addfontform_fontfileZip').on('change', function() {
// need to hide the 'font files' fieldset
$('fieldset.individualfiles').hide(500);
});
$('fieldset.individualfiles input').each(function() {
$(this).change(function() {
$(this).on('change', function() {
// need to hide the 'zip archive' fieldset
$('fieldset.zipfile').hide(500);
});
......
......@@ -144,7 +144,7 @@ EOF;
if ($offset > 0) {
$js .= <<< EOF
if ($('#fontlist').length) {
$('#fontlist a:first').focus();
$('#fontlist a:first').trigger("focus");
}
EOF;
}
......@@ -154,7 +154,7 @@ else {
$('#searchresultsheading')
.addClass('hidefocus')
.prop('tabIndex', 0)
.focus();
.trigger("focus");
}
EOF;
}
......
......@@ -1041,16 +1041,16 @@ jQuery(document).ready(function() {
}
}
// when default account lifetime changes rerun the override account lifetime checks
defaultaccountlifetime.change(function() {
defaultaccountlifetime.on("change", function() {
overrideuseraccountlife(defaultaccountlifetime.val());
});
// initial setup
overrideuseraccountlife(defaultaccountlifetime.val());
jQuery('#siteoptions_institutionstrictprivacy').click(function() {
jQuery('#siteoptions_institutionstrictprivacy').on("click", function() {
multipleinstitutionscheckallowed();
});
jQuery('#siteoptions_usersallowedmultipleinstitutions').click(function() {
jQuery('#siteoptions_usersallowedmultipleinstitutions').on("click", function() {
strictprivacycheckallowed();
});
multipleinstitutionscheckallowed();
......
......@@ -41,7 +41,7 @@ EOF;
if ($offset > 0) {
$js .= <<< EOF
if ($('#myviews')) {
$('#myviews a:first').focus();
$('#myviews a:first').trigger("focus");
}
EOF;
}
......@@ -51,7 +51,7 @@ else {
$('#searchresultsheading')
.addClass('hidefocus')
.prop('tabIndex', -1)
.focus();
.trigger("focus");
}
EOF;
}
......
......@@ -237,7 +237,7 @@ $js = "<script type='application/javascript'>
is_external(authinstanceid);
// update display as auth method dropdown changes
jQuery('#edituser_site_authinstance').change(function() {
jQuery('#edituser_site_authinstance').on('change', function() {
authinstanceid = jQuery('#edituser_site_authinstance :selected').val();
is_external(authinstanceid);
});
......
......@@ -1288,7 +1288,7 @@ jQuery(function($) {
if ($("#institution_theme").val() === "custom") {
$(".customtheme").removeClass("js-hidden");
}
$("#institution_theme").change(function() {
$("#institution_theme").on("change", function() {
if ($(this).val() === "custom") {
$(".customtheme").removeClass("js-hidden");
}
......
......@@ -211,7 +211,7 @@ jQuery(function ($) {
// We need to show/hide modal explicitly so the on 'show.bs.modal' fires allowing
// us to do ajax call for form as modal opens
$('#configbtn').click(function() {
$('#configbtn').on("click", function() {
$("#modal-configs").modal("show");
});
$("#modal-configs").on('show.bs.modal', function () {
......
......@@ -159,14 +159,14 @@ jQuery(function ($) {
show_buttons('$type');
var wireselectall = function() {
$("#selectall").click(function(e) {
$("#selectall").on("click", function(e) {
e.preventDefault();
$("#suspendedlist :checkbox").prop("checked", true);
});
};
var wireselectnone = function() {
$("#selectnone").click(function(e) {
$("#selectnone").on("click", function(e) {
e.preventDefault();
$("#suspendedlist :checkbox").prop("checked", false);
});
......
function addNewPostShortcut(blockid) {
var addentry = jQuery('#blockinstance_' + blockid + ' .blockinstance-content');
addentry.find('a').first().click(function(e) {
addentry.find('a').first().on("click", function(e) {
e.preventDefault();
var blogselect = addentry.find('select').first().val();
if (!blogselect) {
......
......@@ -12,7 +12,7 @@ var addNewTaggedPostShortcut = (function($) {
var myForm = $('<form>', {'action': config.wwwroot + 'artefact/blog/post.php', 'method': 'POST'});
myForm.append(BlogIDInput[0], TagInput);
document.body.appendChild(myForm[0]);
myForm.submit();
myForm.trigger('submit');
});
}
);
......
$j('#instconf_select_container input[type="radio"][value="0"]').click(function() {
$j('#instconf_select_container input[type="radio"][value="0"]').on("click", function() {
$j('#instconf_images_header').addClass('hidden');
$j('#instconf_images_container').addClass('hidden');
$j('#instconf_external_header').addClass('hidden');
......@@ -8,7 +8,7 @@ $j('#instconf_select_container input[type="radio"][value="0"]').click(function()
$j('#instconf_folder_header').removeClass('hidden');
$j('#instconf_folder_container').removeClass('hidden');
});
$j('#instconf_select_container input[type="radio"][value="1"]').click(function() {
$j('#instconf_select_container input[type="radio"][value="1"]').on("click", function() {
$j('#instconf_folder_header').addClass('hidden');
$j('#instconf_folder_container').addClass('hidden');
$j('#instconf_external_header').addClass('hidden');
......@@ -18,7 +18,7 @@ $j('#instconf_select_container input[type="radio"][value="1"]').click(function()
$j('#instconf_images_header').removeClass('hidden');
$j('#instconf_images_container').removeClass('hidden');
});
$j('#instconf_select_container input[type="radio"][value="2"]').click(function() {
$j('#instconf_select_container input[type="radio"][value="2"]').on("click", function() {
$j('#instconf_images_header').addClass('hidden');
$j('#instconf_images_container').addClass('hidden');
$j('#instconf_folder_header').addClass('hidden');
......@@ -28,12 +28,12 @@ $j('#instconf_select_container input[type="radio"][value="2"]').click(function()
$j('#instconf_external').removeClass('hidden');
$j('#externalgalleryhelp').removeClass('hidden');
});
$j('#instconf_style_container input[type="radio"][value="0"]').click(function () {
$j('#instconf_style_container input[type="radio"][value="0"]').on("click", function () {
$j('#instconf_width').val('75');
});
$j('#instconf_style_container input[type="radio"][value="1"]').click(function () {
$j('#instconf_style_container input[type="radio"][value="1"]').on("click", function () {
$j('#instconf_width').val('400');
});
$j('#instconf_style_container input[type="radio"][value="2"]').click(function () {
$j('#instconf_style_container input[type="radio"][value="2"]').on("click", function () {
$j('#instconf_width').val('75');
});
......@@ -585,7 +585,7 @@ var FileBrowser = (function($) {
cancellink.on('click keydown', function(e) {
if ((e.type === 'click' || e.keyCode === 32) && !e.isDefaultPrevented()) {
wrapper.remove();
icon.focus();
icon.trigger("focus");
self.move_list = null;
e.preventDefault();
}
......@@ -604,7 +604,7 @@ var FileBrowser = (function($) {
if (e.type === 'click' || e.keyCode === 32 || e.keyCode === 13) {
var folderlist = self.create_move_list(icon, id);
$(icon).closest('tr').find('.filename').append(folderlist);
folderlist.find('a').first().focus();
folderlist.find('a').first().trigger("focus");
e.preventDefault();
}
});
......@@ -886,7 +886,7 @@ var FileBrowser = (function($) {
// are we running inside tinymce imagebrowser plugin?
if (window.imgbrowserconf_artefactid) {
// propagate the click
$('#filebrowserupdatetarget').click();
$('#filebrowserupdatetarget').trigger("click");
}
};
......@@ -977,11 +977,11 @@ var FileBrowser = (function($) {
// Focus management
if (self.setfocus) {
$('#' + self.setfocus)[0].focus();
$( $('#' + self.setfocus)[0] ).trigger('focus');
self.setfocus = null;
}
else if (data.foldercreated) {
$('[id="changefolder:' + data.highlight + '"]')[0].focus();
$( $('[id="changefolder:' + data.highlight + '"]')[0]).trigger('focus');
}
if (data.changedfolder && data.newpath) {
......
$j('#instconf_socialprofile_container input[type="radio"][value="0"]').click(function() {
$j('#instconf_socialprofile_container input[type="radio"][value="0"]').on("click", function() {
$j('#instconf_socialprofileids_header').addClass('hidden');
$j('#instconf_socialprofileids_container').addClass('hidden');
});
$j('#instconf_socialprofile_container input[type="radio"][value="1"]').click(function() {
$j('#instconf_socialprofile_container input[type="radio"][value="1"]').on("click", function() {
$j('#instconf_socialprofileids_header').removeClass('hidden');
$j('#instconf_socialprofileids_container').removeClass('hidden');
});
......@@ -194,7 +194,7 @@ $pagination = build_pagination(array(
$js = '
jQuery(function($) {
$("a.notetitle").click(function(e) {
$("a.notetitle").on("click", function(e) {
e.preventDefault();
$("#" + this.id + "_desc").toggleClass("hidden");
});
......
......@@ -29,11 +29,11 @@ $skills = ArtefactTypeResumeGoalAndSkill::get_goals_and_skills('skills');
$js = '
jQuery(function($) {
$("a.goaltitle").click(function(e) {
$("a.goaltitle").on("click", function(e) {
e.preventDefault();
$j("#" + this.id + "_desc").toggleClass("hidden");
});
$("a.skilltitle").click(function(e) {
$("a.skilltitle").on("click", function(e) {
e.preventDefault();
$("#" + this.id + "_desc").toggleClass("hidden");
});
......
......@@ -5,7 +5,7 @@ jQuery(function($) {
"use strict";
simpleresume.connect_editbuttons = function() {
$("#resumefieldform input.openedit").click(function() {
$("#resumefieldform input.openedit").on("click", function() {
//takes id and removes the word 'edit' from the end...
var t = this.id.substr(0, this.id.length - 4),
container = $("#" + t + "_container"),
......@@ -34,13 +34,13 @@ jQuery(function($) {
document.location.href = "#" + formTop;
}
else {
$("#" + t).removeClass("js-hidden").focus();
$("#" + t).removeClass("js-hidden").trigger("focus");
}
});
};
simpleresume.connect_cancelbuttons = function() {
$("#resumefieldform input.submitcancel.cancel").click(function(e) {
$("#resumefieldform input.submitcancel.cancel").on("click", function(e) {
e.preventDefault();
//takes id and removes the word 'cancel' from the end...
var t = this.id.substr(7, this.id.length - 7 - 6),
......@@ -64,7 +64,7 @@ jQuery(function($) {
else {
$("#" + t).addClass("js-hidden");
}
$("#" + t + "edit_container").find('input.openedit').focus();
$("#" + t + "edit_container").find('input.openedit').trigger("focus");
});
};
......@@ -106,7 +106,7 @@ function simple_resumefield_error(form, data) {
if (errornodeid) {
var editbutton = jQuery("input#" + errornodeid + "edit");
if (editbutton) {
editbutton.click();
editbutton.trigger("click");
}
}
}
......@@ -987,7 +987,7 @@ function compositeSaveCallback(form, data) {
\$j('#' + key + 'form').collapse('hide');
tableRenderers[key].doupdate(null, { focusid: data['focusid'] });
\$j('#add' + key + 'button').focus();
\$j('#add' + key + 'button').trigger("focus");
// Do a double check to make sure the formchange checker for the submitted form is actually reset
tableRenderers[key].postupdatecallback = function(response) {
var checkers = formchangemanager.formcheckers;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment