Adjustements for jquery update
authorJean-Michel Vourgère <nirgal@debian.org>
Mon, 23 Dec 2019 14:23:12 +0000 (15:23 +0100)
committerRobert Treat <xzilla@users.noreply.github.com>
Wed, 7 Oct 2020 02:18:30 +0000 (22:18 -0400)
- 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.

classes/Misc.php
js/ac_insert_row.js
js/database.js
js/display.js

index 7df578cc6b395d7c7b82e5b103a650c8d27c7218..e96606481fb8c6dda5779cc9c60b2fd8c57b5bbf 100644 (file)
                                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";
                                $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;
                                                });
 
                                if (isset($_SESSION['sharedUsername'])) {
                                        printf("
-                                               $('#toplink_logout').click(function() {
+                                               $('#toplink_logout').on('click', function() {
                                                        return confirm('%s');
                                                });", str_replace("'", "\'", $lang['strconfdropcred']));
                                }
index deee0f953f4f41b6261f32f0e0bcafa477b71433..31a52402e28d8c9f2a62c0dd4e7bca404a09b79e 100644 (file)
@@ -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
        );
index f70f7078658d27f1b398f360a76b54f3ab2092cf..11c21bfc04141e8e3e8334cdf36fe72daf69ef11 100644 (file)
@@ -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');
 });
index bac28ecb8be2c1f640cab3e4bc86f3f00c6c21eb..ad27de31af0bd52bbd3ad2823a9ad7ee1c5989b2 100644 (file)
@@ -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();