summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Michel Vourgère2019-12-23 14:23:12 +0000
committerRobert Treat2020-10-07 02:18:30 +0000
commitbf0572a7d4d31d53cc26cd75e94daf3fbd0d5510 (patch)
treebf58caee7da0abe0fd1fbd3264937c5a0b4d07a5
parentf28e894fb398558948ec597c667e1110198dbf34 (diff)
Adjustements for jquery update
- Replaced .click(function) by .on('click', function) - Replaced .click() by .trigger('click') - Replaced .live(event, function) by .on(event, function) - Replaced $(document).ready(function) by $(function) - Replaced .bind/.unbind by .on/.off - Replaced keypress events by keydown events, so that up/down keys get supported again. Thanks to the jquery-migrate project.
-rw-r--r--classes/Misc.php10
-rw-r--r--js/ac_insert_row.js47
-rw-r--r--js/database.js15
-rw-r--r--js/display.js6
4 files changed, 38 insertions, 40 deletions
diff --git a/classes/Misc.php b/classes/Misc.php
index 7df578cc..e9660648 100644
--- a/classes/Misc.php
+++ b/classes/Misc.php
@@ -545,7 +545,7 @@
echo "<link rel=\"icon\" type=\"image/png\" href=\"images/themes/{$conf['theme']}/Introduction.png\" />\n";
echo "<script type=\"text/javascript\" src=\"libraries/js/jquery.js\"></script>";
echo "<script type=\"text/javascript\">// <!-- \n";
- echo "$(document).ready(function() { \n";
+ echo "$(function() { \n";
echo " if (window.parent.frames.length > 1)\n";
echo " $('#csstheme', window.parent.frames[0].document).attr('href','themes/{$conf['theme']}/global.css');\n";
echo "}); // --></script>\n";
@@ -1416,17 +1416,17 @@
$history_window_id = htmlentities('history:'.$_REQUEST['server']);
echo "<script type=\"text/javascript\">
- $('#toplink_sql').click(function() {
+ $('#toplink_sql').on('click', function() {
window.open($(this).attr('href'),'{$sql_window_id}','toolbar=no,width=700,height=500,resizable=yes,scrollbars=yes').focus();
return false;
});
- $('#toplink_history').click(function() {
+ $('#toplink_history').on('click', function() {
window.open($(this).attr('href'),'{$history_window_id}','toolbar=no,width=700,height=500,resizable=yes,scrollbars=yes').focus();
return false;
});
- $('#toplink_find').click(function() {
+ $('#toplink_find').on('click', function() {
window.open($(this).attr('href'),'{$sql_window_id}','toolbar=no,width=700,height=500,resizable=yes,scrollbars=yes').focus();
return false;
});
@@ -1434,7 +1434,7 @@
if (isset($_SESSION['sharedUsername'])) {
printf("
- $('#toplink_logout').click(function() {
+ $('#toplink_logout').on('click', function() {
return confirm('%s');
});", str_replace("'", "\'", $lang['strconfdropcred']));
}
diff --git a/js/ac_insert_row.js b/js/ac_insert_row.js
index deee0f95..31a52402 100644
--- a/js/ac_insert_row.js
+++ b/js/ac_insert_row.js
@@ -14,15 +14,15 @@ function hideAc() {
function triggerAc(ac) {
if (ac) {
jQuery.ppa.attrs
- .bind('keyup.ac_action', autocomplete)
- .bind('focus.ac_action', autocomplete)
- .bind('keypress.ac_action', move)
+ .on('keyup.ac_action', autocomplete)
+ .on('focus.ac_action', autocomplete)
+ .on('keydown.ac_action', move)
.addClass('ac_field');
}
else {
jQuery.ppa.attrs
.removeClass('ac_field')
- .unbind('.ac_action');
+ .off('.ac_action');
}
}
@@ -90,6 +90,7 @@ function openlist(e) {
show();
jQuery.ppa.numrow = find('tr').length;
}
+
}
});
}
@@ -135,7 +136,7 @@ function autocomplete(event) {
/* if pressing enter, fire a click on the selected line */
if (event.keyCode == 13) {
if (jQuery.ppa.i > 0) {
- jQuery.ppa.fklist.find('tr').eq(jQuery.ppa.i).click();
+ jQuery.ppa.fklist.find('tr').eq(jQuery.ppa.i).trigger('click');
}
return false;
}
@@ -166,23 +167,19 @@ function autocomplete(event) {
return true;
}
-/* bind actions on values lines: hover for style change, click for select */
-with(jQuery('tr.acline')) {
- live('mouseover', function () {
- selectVal(jQuery('table.ac_values tr').index(this));
- });
-
- live('click', function () {
- var a = jQuery(this).find('td > a.fkval');
+$(document).on('mouseover', 'tr.acline', function() {
+ selectVal(jQuery('table.ac_values tr').index(this));
+});
- for (i=0; i < a.length; i++) {
- jQuery('input[name="values['+ a[i].name +']"]').val(jQuery(a[i]).text());
- }
- hideAc();
- });
-}
+$(document).on('click', 'tr.acline', function() {
+ var a = jQuery(this).find('td > a.fkval');
+ for (i=0; i < a.length; i++) {
+ jQuery('input[name="values['+ a[i].name +']"]').val(jQuery(a[i]).text());
+ }
+ hideAc();
+});
-jQuery('#fkprev').live('click', function () {
+$(document).on('click', '#fkprev', function () {
jQuery.ppa.o -= 11;
/* get the field that is the previous html elt from the #fklist
* and trigger its focus to refresh the list AND actually
@@ -190,7 +187,7 @@ jQuery('#fkprev').live('click', function () {
jQuery('#fklist').prev().focus();
});
-jQuery('#fknext').live('click', function () {
+$(document).on('click', '#fknext', function () {
jQuery.ppa.o += 11;
/* get the field that is the previous html elt from the #fklist
* and trigger its focus to refresh the list AND actually
@@ -198,7 +195,7 @@ jQuery('#fknext').live('click', function () {
jQuery('#fklist').prev().focus();
});
-jQuery(document).ready(function () {
+jQuery(function () {
/* register some global value in the ppa namespace */
jQuery.ppa = {
fklist: jQuery('#fklist'),
@@ -209,20 +206,20 @@ jQuery(document).ready(function () {
};
/* close the list when clicking outside of it */
- jQuery.ppa.fkbg.click(function (e) {
+ jQuery.ppa.fkbg.on('click', function (e) {
hideAc();
});
/* do not submit the form when selecting a value by pressing enter */
jQuery.ppa.attrs
- .keydown(function (e) {
+ .on('keydown', function (e) {
if (e.keyCode == 13 && jQuery.ppa.fklist[0].style.display == 'block')
return false;
});
/* enable/disable auto-complete according to the checkbox */
triggerAc(
- jQuery('#no_ac').click(function () {
+ jQuery('#no_ac').on('click', function () {
triggerAc(this.checked);
})[0].checked
);
diff --git a/js/database.js b/js/database.js
index f70f7078..11c21bfc 100644
--- a/js/database.js
+++ b/js/database.js
@@ -1,4 +1,4 @@
-$(document).ready(function() {
+$(function() {
var timeid = query = null;
var controlLink = $('#control');
@@ -34,24 +34,25 @@ $(document).ready(function() {
}
}
- controlLink.toggle(
- function() {
+ controlLink.on('click', function() {
+ if (!timeid) {
$(errmsg).hide();
timeid = window.setTimeout(refreshTable, Database.ajax_time_refresh);
controlLink.html('<img src="'+ Database.str_stop.icon +'" alt="" />&nbsp;'
+ Database.str_stop.text + '&nbsp;&nbsp;&nbsp;'
);
- },
- function() {
+ } else {
$(errmsg).hide();
$(loading).hide();
window.clearInterval(timeid);
+ timeid = null;
if (query) query.abort();
controlLink.html('<img src="'+ Database.str_start.icon +'" alt="" />&nbsp;'
+ Database.str_start.text
);
}
- );
+ return false; /* disable event propagation */
+ });
/* preload images */
$('#control img').hide()
@@ -60,5 +61,5 @@ $(document).ready(function() {
.show();
/* start refreshing */
- controlLink.click();
+ controlLink.trigger('click');
});
diff --git a/js/display.js b/js/display.js
index bac28ecb..ad27de31 100644
--- a/js/display.js
+++ b/js/display.js
@@ -1,4 +1,4 @@
-$(document).ready(function() {
+$(function() {
/* init some needed tags and values */
@@ -9,7 +9,7 @@ $(document).ready(function() {
root: $('#root')
};
- $("a.fk").live('click', function (event) {
+ $("a.fk").on('click', function (event) {
/* make the cursor being a waiting cursor */
$('body').css('cursor','wait');
@@ -80,7 +80,7 @@ $(document).ready(function() {
return false; // do not refresh the page
});
- $(".fk_delete").live('click', function (event) {
+ $(document).on('click', '.fk_delete', function (event) {
with($(this).closest('div')) {
data('ref').closest('tr').find('a.'+data('refclass')).closest('div').removeClass('highlight');
remove();