From 9f13865777c8631979eb31c35750e9700d7e18b8 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Fri, 25 May 2018 16:26:37 +0100 Subject: [PATCH] Update jQuery to 3.3.1. Fixes #3271 Patch by Aditya, with test enhancements from Anthony and Joao at Pivotal. --- libraries.txt | 2 +- web/package.json | 2 +- .../schemas/tables/column/static/js/column.js | 2 +- .../servers/static/js/privilege.js | 4 +- .../servers/static/js/variable.js | 2 +- web/pgadmin/browser/static/js/browser.js | 2 +- web/pgadmin/browser/static/js/keyboard.js | 8 +- web/pgadmin/browser/static/js/menu.js | 4 +- web/pgadmin/browser/static/js/node.js | 16 ++-- web/pgadmin/dashboard/static/js/dashboard.js | 10 +-- .../file_manager/static/js/file_manager.js | 4 +- .../misc/file_manager/static/js/utility.js | 44 +++++----- web/pgadmin/misc/static/explain/js/explain.js | 10 +-- .../static/js/alertify.pgadmin.defaults.js | 4 +- web/pgadmin/static/js/backform.pgadmin.js | 12 +-- web/pgadmin/static/js/backgrid.pgadmin.js | 6 +- web/pgadmin/static/js/keyboard_shortcuts.js | 2 +- web/pgadmin/tools/backup/static/js/backup.js | 4 +- .../tools/datagrid/static/js/datagrid.js | 2 +- .../datagrid/templates/datagrid/index.html | 2 +- .../tools/debugger/static/js/debugger.js | 6 +- .../tools/debugger/static/js/debugger_ui.js | 2 +- .../tools/debugger/static/js/direct.js | 2 +- .../grant_wizard/static/js/grant_wizard.js | 3 +- .../import_export/static/js/import_export.js | 2 +- .../tools/restore/static/js/restore.js | 2 +- .../static/js/user_management.js | 4 +- .../selection/column_selector_spec.js | 2 +- .../selection/grid_selector_spec.js | 14 +-- .../slickgrid/cell_selector_spec.js | 4 +- .../sqleditor/execute_query_spec.js | 85 ++++++------------- web/yarn.lock | 6 +- 32 files changed, 120 insertions(+), 154 deletions(-) diff --git a/libraries.txt b/libraries.txt index 17f85cfc5..4a33ef2df 100644 --- a/libraries.txt +++ b/libraries.txt @@ -5,7 +5,7 @@ Library Version Licence URL ======= ======= ======= === QT 4.6.2+ LGPL v2.1/3 http://www.qt.io/ Bootstrap 3.3.4 MIT http://getbootstrap.com/ -jQuery 1.11.1 MIT http://jquery.com/ +jQuery 3.3.1 MIT http://jquery.com/ Modernizr 2.6.2 MIT/BSD http://modernizr.com/ AlertifyJS 1.7.1 MIT http://alertifyjs.com/ *** Do not update - changed to GPL3 in 1.8.0 *** CodeMirror 5.14.2 MIT http://codemirror.net/ diff --git a/web/package.json b/web/package.json index b9953b642..6ccc4ee67 100644 --- a/web/package.json +++ b/web/package.json @@ -69,7 +69,7 @@ "immutability-helper": "^2.2.0", "imports-loader": "^0.7.1", "ip-address": "^5.8.9", - "jquery": "^1.12.4", + "jquery": "3.3.1", "jquery-contextmenu": "^2.6.4", "jquery-ui": "^1.12.1", "moment": "^2.20.1", diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js index 72b6eb0c8..3eac530d0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/static/js/column.js @@ -287,7 +287,7 @@ define('pgadmin.node.column', [ var command = new Backgrid.Command({key: 'Tab', keyCode: 9, which: 9}); self.model.trigger('backgrid:edited', self.model, self.column, command); - next_cell.focus(); + next_cell.trigger('focus'); } }, 20); }, diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js index 64557a095..6758bf6a6 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js @@ -381,10 +381,10 @@ define(['sources/gettext', 'underscore', 'jquery', 'backbone', 'backform', 'header': true, })); } - self.$el.find('input[type=checkbox]').first().focus(); + self.$el.find('input[type=checkbox]').first().trigger('focus'); // Since blur event does not bubble we need to explicitly call parent's blur event. $(self.$el.find('input[type=checkbox]')).on('blur',function() { - self.$el.blur(); + self.$el.trigger('blur'); }); // Make row visible in when entering in edit mode. diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js index 2c5bb07a7..9e48b4f9b 100644 --- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js +++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js @@ -395,7 +395,7 @@ define([ // Add button callback if (!(data.disabled || data.canAdd == false)) { - $gridBody.find('button.add').first().click(function(e) { + $gridBody.find('button.add').first().on('click',(e) => { e.preventDefault(); var canAddRow = _.isFunction(data.canAddRow) ? data.canAddRow.apply(self, [self.model]) : true; diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index d9693486a..b26738cfe 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -1609,7 +1609,7 @@ define('pgadmin.browser', [ jsonResp = ( contentType && contentType.indexOf('application/json') == 0 && - $.parseJSON(xhr.responseText) + JSON.parse(xhr.responseText) ) || {}; if (xhr.status == 410 && jsonResp.success == 0) { diff --git a/web/pgadmin/browser/static/js/keyboard.js b/web/pgadmin/browser/static/js/keyboard.js index e4e1da1dd..371faa5d8 100644 --- a/web/pgadmin/browser/static/js/keyboard.js +++ b/web/pgadmin/browser/static/js/keyboard.js @@ -142,18 +142,18 @@ _.extend(pgBrowser.keyboardNavigation, { bindMainMenuUpDown: function(event, combo) { // Handle Sub-menus if (combo === 'up' && $(event.target).parent().prev().prev('.dropdown-submenu').length > 0) { - $(event.target).parent().prev().prev('.dropdown-submenu').find('a:first').focus(); + $(event.target).parent().prev().prev('.dropdown-submenu').find('a:first').trigger('focus'); } else { if ($(event.target).parent().hasClass('dropdown-submenu')) { $(event.target).parent().parent().parent().find('a:first').dropdown('toggle'); - $(event.target).parent().parent().children().eq(2).find('a:first').focus(); + $(event.target).parent().parent().children().eq(2).find('a:first').trigger('focus'); } } }, bindLeftTree: function() { const tree = this.getTreeDetails(); - $('#tree').focus(); + $('#tree').trigger('focus'); tree.t.focus(tree.i); tree.t.select(tree.i); }, @@ -219,7 +219,7 @@ _.extend(pgBrowser.keyboardNavigation, { const top = $(event.srcElement).find('.aciTreeEntry').position().top + 70; tree.t.blur(tree.i); - $('#tree').blur(); + $('#tree').trigger('blur'); // Call context menu and set position tree.i.children().contextMenu({x: left, y: top}); }, diff --git a/web/pgadmin/browser/static/js/menu.js b/web/pgadmin/browser/static/js/menu.js index db3b92a34..d236a8970 100644 --- a/web/pgadmin/browser/static/js/menu.js +++ b/web/pgadmin/browser/static/js/menu.js @@ -95,10 +95,10 @@ define([ element.find('i').addClass('font-white'); element.find('i').removeClass('font-gray-4'); - span.mouseover(function() { + span.on('mouseover',() => { element.addClass('bg-gray-5'); }); - span.mouseout(function() { + span.on('mouseout',() => { element.removeClass('bg-gray-5'); }); }, diff --git a/web/pgadmin/browser/static/js/node.js b/web/pgadmin/browser/static/js/node.js index ad5824839..460ab03d7 100644 --- a/web/pgadmin/browser/static/js/node.js +++ b/web/pgadmin/browser/static/js/node.js @@ -734,7 +734,7 @@ define('pgadmin.browser.node', [ /* Error from the server */ if (jqx.status == 417 || jqx.status == 410 || jqx.status == 500) { try { - var data = $.parseJSON(jqx.responseText); + var data = JSON.parse(jqx.responseText); msg = data.errormsg; } catch (e) { console.warn(e.stack || e); @@ -1140,7 +1140,7 @@ define('pgadmin.browser.node', [ icon: 'fa fa-lg fa-pencil-square-o', disabled: !that.canEdit, register: function(btn) { - btn.click(function() { + btn.on('click',() => { onEdit(); }); }, @@ -1154,7 +1154,7 @@ define('pgadmin.browser.node', [ icon: 'fa fa-lg fa-info', disabled: (that.sqlAlterHelp == '' && that.sqlCreateHelp == '') ? true : false, register: function(btn) { - btn.click(function() { + btn.on('click',() => { onSqlHelp(); }); }, @@ -1359,7 +1359,7 @@ define('pgadmin.browser.node', [ icon: 'fa fa-lg fa-info', disabled: (that.sqlAlterHelp == '' && that.sqlCreateHelp == '') ? true : false, register: function(btn) { - btn.click(function() { + btn.on('click',() => { onSqlHelp(); }); }, @@ -1371,7 +1371,7 @@ define('pgadmin.browser.node', [ icon: 'fa fa-lg fa-question', disabled: (that.dialogHelp == '') ? true : false, register: function(btn) { - btn.click(function() { + btn.on('click',() => { onDialogHelp(); }); }, @@ -1384,7 +1384,7 @@ define('pgadmin.browser.node', [ disabled: true, register: function(btn) { // Save the changes - btn.click(function() { + btn.on('click',() => { onSave.call(this, view, btn); }); }, @@ -1396,7 +1396,7 @@ define('pgadmin.browser.node', [ icon: 'fa fa-lg fa-close', disabled: false, register: function(btn) { - btn.click(function() { + btn.on('click',() => { // Removing the action-mode panel.$container.removeAttr('action-mode'); onCancelFunc.call(arguments); @@ -1410,7 +1410,7 @@ define('pgadmin.browser.node', [ icon: 'fa fa-lg fa-recycle', disabled: true, register: function(btn) { - btn.click(function() { + btn.on('click',() => { setTimeout(function() { editFunc.call(); }, 0); diff --git a/web/pgadmin/dashboard/static/js/dashboard.js b/web/pgadmin/dashboard/static/js/dashboard.js index 686cbf244..5c812bf5a 100644 --- a/web/pgadmin/dashboard/static/js/dashboard.js +++ b/web/pgadmin/dashboard/static/js/dashboard.js @@ -63,9 +63,9 @@ define('pgadmin.dashboard', [ // This will refresh the grid var refresh_grid = function() { if (is_server_dashboard) { - $('#btn_server_activity_refresh').click(); + $('#btn_server_activity_refresh').trigger('click'); } else if (is_database_dashboard) { - $('#btn_database_activity_refresh').click(); + $('#btn_database_activity_refresh').trigger('click'); } }; @@ -139,7 +139,7 @@ define('pgadmin.dashboard', [ ); this.delegateEvents(); if (this.grabFocus) - this.$el.focus(); + this.$el.trigger('focus'); return this; }, }); @@ -969,7 +969,7 @@ define('pgadmin.dashboard', [ }); // Handle button clicks - $('button').click(function() { + $('button').on('click',() => { switch (this.id) { case 'btn_server_activity_refresh': pgAdmin.Dashboard.render_grid_data(div_server_activity); @@ -1290,7 +1290,7 @@ define('pgadmin.dashboard', [ }); // Handle button clicks - $('button').click(function() { + $('button').on('click',() => { switch (this.id) { case 'btn_database_activity_refresh': pgAdmin.Dashboard.render_grid_data(div_database_activity); diff --git a/web/pgadmin/misc/file_manager/static/js/file_manager.js b/web/pgadmin/misc/file_manager/static/js/file_manager.js index 10de1ea86..11fa2e78d 100644 --- a/web/pgadmin/misc/file_manager/static/js/file_manager.js +++ b/web/pgadmin/misc/file_manager/static/js/file_manager.js @@ -574,7 +574,7 @@ define('misc.file_manager', [ $('.file_manager_ok').addClass('disabled'); $('.replace_file, .fm_dimmer').show(); - $yesBtn.click(function() { + $yesBtn.on('click',() => { $('.replace_file, .fm_dimmer').hide(); $yesBtn.off(); $noBtn.off(); @@ -586,7 +586,7 @@ define('misc.file_manager', [ $('.file_manager_ok').removeClass('disabled'); }); - $noBtn.click(function() { + $noBtn.on('click',() => { $('.replace_file, .fm_dimmer').hide(); $yesBtn.off(); $noBtn.off(); diff --git a/web/pgadmin/misc/file_manager/static/js/utility.js b/web/pgadmin/misc/file_manager/static/js/utility.js index 249b0fe8d..ce3cd1702 100755 --- a/web/pgadmin/misc/file_manager/static/js/utility.js +++ b/web/pgadmin/misc/file_manager/static/js/utility.js @@ -133,13 +133,13 @@ define([ if (!has_capability(data, 'delete') || pgAdmin.FileUtils.hideButtons()) { $('.file_manager').find('button.delete').hide(); } else { - $('.file_manager').find('button.delete').click(function() { + $('.file_manager').find('button.delete').on('click',() => { // hide dimmer $('.fileinfo .delete_item, .fm_dimmer').show(); }); // take action based on pressed button yes or no - $('.fileinfo .delete_item button.btn_yes').unbind().on('click', function() { + $('.fileinfo .delete_item button.btn_yes').off().on('click', function() { var path; if ($('.fileinfo').data('view') == 'grid') { path = decodeURI($('.fileinfo').find('#contents li.selected .clip span').attr('data-alt')); @@ -168,7 +168,7 @@ define([ if (!has_capability(data, 'download') || pgAdmin.FileUtils.hideButtons()) { $('.file_manager').find('button.download').hide(); } else { - $('.file_manager').find('button.download').unbind().click(function() { + $('.file_manager').find('button.download').off().on('click',() => { var path; if ($('.fileinfo').data('view') == 'grid') { path = $('.fileinfo li.selected').find('.clip span').attr('data-alt'); @@ -266,7 +266,7 @@ define([ data.Filename = newName; // UnBind toolbar functions. - $('.fileinfo').find('button.rename, button.delete, button.download').unbind(); + $('.fileinfo').find('button.rename, button.delete, button.download').off(); Alertify.success(lg.successful_rename); } else { @@ -443,7 +443,7 @@ define([ } // navigate to directory or path when clicked on breadcrumbs - $('.file_manager a.breadcrumbs').unbind().on('click', function() { + $('.file_manager a.breadcrumbs').off().on('click', function() { var curr_path = $(this).attr('data-path'), current_dir = $(this).html(), move_to = curr_path.substring( @@ -669,7 +669,7 @@ define([ $('.fileinfo .file_listing').html(result); // rename file/folder - $('.file_manager button.rename').unbind().on('click', function(e) { + $('.file_manager button.rename').off().on('click', function(e) { if ($('.fileinfo').data('view') == 'grid') { e.stopPropagation(); @@ -681,11 +681,11 @@ define([ newvalue = decodeURI(orig_value); } - $this.find('input').toggle().val(newvalue).focus(); + $this.find('input').toggle().val(newvalue).trigger('focus'); $this.find('span').toggle(); // Rename folder/file on pressing enter key - $('.file_manager').unbind().on('keyup', function(e) { + $('.file_manager').off().on('keyup', function(e) { if (e.keyCode == 13) { e.stopPropagation(); $('.fileinfo #contents li.selected p').find( @@ -705,11 +705,11 @@ define([ newvalue = decodeURI(orig_value); } - $this.find('input').toggle().val(newvalue).focus(); + $this.find('input').toggle().val(newvalue).trigger('focus'); $this.find('span').toggle(); // Rename folder/file on pressing enter key - $('.file_manager').unbind().on('keyup', function(e) { + $('.file_manager').off().on('keyup', function(e) { if (e.keyCode == 13) { e.stopPropagation(); $('.fileinfo table#contents tr.selected td p').find( @@ -866,12 +866,12 @@ define([ } else { var is_valid_file = getFileInfo(path); if (is_valid_file && check_file_capability(e, data_cap, 'grid')) { - $('.file_manager_ok').click(); + $('.file_manager_ok').trigger('click'); } } }); - $('.fileinfo').find('#contents li').click(function(e) { + $('.fileinfo').find('#contents li').on('click',(e) => { e.stopPropagation(); var path = decodeURI($(this).find('.clip span').attr('data-alt')), is_protected = $(this).find( @@ -976,7 +976,7 @@ define([ if ( is_valid_file && check_file_capability(e, data_cap, 'table') ) { - $('.file_manager_ok').click(); + $('.file_manager_ok').trigger('click'); } } }); @@ -1131,7 +1131,7 @@ define([ // If user have preference to show hidden files if (config.options.show_hidden_files) { setTimeout(function() { - $('#show_hidden').click(); + $('#show_hidden').trigger('click'); }, 10); } // handle show hidden files functionality @@ -1199,7 +1199,7 @@ define([ ).on( 'click', function(e) { - $('#uploader .filemanager-btn-group').unbind().on( + $('#uploader .filemanager-btn-group').off().on( 'click', function() { $('.fileinfo .delete_item, .fileinfo .replace_file, .fileinfo .fm_dimmer').hide(); @@ -1221,7 +1221,7 @@ define([ }); // re-render the home view - $('.file_manager .home').click(function() { + $('.file_manager .home').on('click',() => { var currentViewMode = $('.fileinfo').data('view'); $('.fileinfo').data('view', currentViewMode); getFolderInfo('/'); @@ -1229,7 +1229,7 @@ define([ }); // Go one directory back - $('.file_manager .level-up').click(function() { + $('.file_manager .level-up').on('click',() => { var b = $('.currentpath').val(); // Enable/Disable level up button enab_dis_level_up(); @@ -1253,7 +1253,7 @@ define([ }); // set buttons to switch between grid and list views. - $('.file_manager .grid').click(function() { + $('.file_manager .grid').on('click',() => { setViewButtonsFor('grid'); $('.fileinfo').data('view', 'grid'); enable_disable_btn(); @@ -1262,7 +1262,7 @@ define([ }); // Show list mode - $('.file_manager .list').click(function() { + $('.file_manager .list').on('click',() => { setViewButtonsFor('list'); $('.fileinfo').data('view', 'list'); enable_disable_btn(); @@ -1387,7 +1387,7 @@ define([ $('.upload').remove(); $('.create').before(' '); - $('#uploader .upload').unbind().click(function() { + $('#uploader .upload').off().on('click',() => { // we create prompt var msg = '
' + '' + @@ -1443,7 +1443,7 @@ define([ acceptedFiles: acceptFiles, autoProcessQueue: true, init: function() { - $('.dz_cross_btn').unbind().on('click', function() { + $('.dz_cross_btn').off().on('click', function() { $('.file_manager .upload_file').toggle(); }); }, @@ -1533,7 +1533,7 @@ define([ $('.storage_dialog #uploader .input-path').attr('data-path', path); // create new folder - $('.create').unbind().click(function() { + $('.create').off().on('click',() => { var foldername = lg.new_folder; var $file_element, $file_element_list, diff --git a/web/pgadmin/misc/static/explain/js/explain.js b/web/pgadmin/misc/static/explain/js/explain.js index f406c3c47..61cf8f90a 100644 --- a/web/pgadmin/misc/static/explain/js/explain.js +++ b/web/pgadmin/misc/static/explain/js/explain.js @@ -576,7 +576,7 @@ define('pgadmin.misc.explain', [ // Draw tooltip var image_data = this.toJSON(); - image.mouseover(function() { + image.on('mouseover',() => { // Empty the tooltip content if it has any and add new data toolTipContainer.empty(); @@ -618,7 +618,7 @@ define('pgadmin.misc.explain', [ }); // Remove tooltip when mouse is out from node's area - image.mouseout(function() { + image.on('mouseout',() => { toolTipContainer.empty(); toolTipContainer.css({ 'opacity': '0', @@ -851,7 +851,7 @@ define('pgadmin.misc.explain', [ 'height': h * curr_zoom_factor, }); planDiv.data('zoom-factor', curr_zoom_factor); - zoomInBtn.blur(); + zoomInBtn.trigger('blur'); }); zoomOutBtn.on('click', function() { @@ -867,7 +867,7 @@ define('pgadmin.misc.explain', [ 'height': h * curr_zoom_factor, }); planDiv.data('zoom-factor', curr_zoom_factor); - zoomOutBtn.blur(); + zoomOutBtn.trigger('blur'); }); zoomToNormal.on('click', function() { @@ -883,7 +883,7 @@ define('pgadmin.misc.explain', [ 'height': h * curr_zoom_factor, }); planDiv.data('zoom-factor', curr_zoom_factor); - zoomToNormal.blur(); + zoomToNormal.trigger('blur'); }); }); diff --git a/web/pgadmin/static/js/alertify.pgadmin.defaults.js b/web/pgadmin/static/js/alertify.pgadmin.defaults.js index 887d08fca..7c4998026 100644 --- a/web/pgadmin/static/js/alertify.pgadmin.defaults.js +++ b/web/pgadmin/static/js/alertify.pgadmin.defaults.js @@ -96,7 +96,7 @@ define([ if (contentType) { try { if (contentType.indexOf('application/json') == 0) { - var resp = $.parseJSON(msg); + var resp = JSON.parse(msg); if (resp.result != null && (!resp.errormsg || resp.errormsg == '') && onJSONResult && typeof(onJSONResult) == 'function') { @@ -253,7 +253,7 @@ define([ var contentType = xhr.getResponseHeader('Content-Type'), jsonResp = contentType && contentType.indexOf('application/json') == 0 && - $.parseJSON(xhr.responseText); + JSON.parse(xhr.responseText); if ( jsonResp && ( diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index 97c52e114..c7b984966 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -1081,7 +1081,7 @@ define([ // Add button callback if (!(data.disabled || data.canAdd == false)) { - $dialog.find('button.add').first().click(function(e) { + $dialog.find('button.add').first().on('click',(e) => { e.preventDefault(); var canAddRow = _.isFunction(data.canAddRow) ? data.canAddRow.apply(self, [self.model]) : true; @@ -1361,7 +1361,7 @@ define([ var $dialog = gridBody.append(subNodeGrid); // Add button callback - $dialog.find('button.add').click(function(e) { + $dialog.find('button.add').on('click',(e) => { e.preventDefault(); var canAddRow = _.isFunction(data.canAddRow) ? data.canAddRow.apply(self, [self.model]) : true; @@ -1379,7 +1379,7 @@ define([ grid.insertRow({}); var newRow = $(grid.body.rows[collection.length - 1].$el); - newRow.attr('class', 'new').click(function() { + newRow.attr('class', 'new').on('click',() => { $(this).attr('class', 'editable'); }); $(newRow).pgMakeVisible('backform-tab'); @@ -2367,7 +2367,7 @@ define([ if (widget) { setTimeout(function() { picker.toggle(); - self.$el.find('input').first().blur(); + self.$el.find('input').first().trigger('blur'); }, 10); } else { setTimeout(function() { @@ -2380,7 +2380,7 @@ define([ // blur the input setTimeout( function() { - self.$el.find('input').first().blur(); + self.$el.find('input').first().trigger('blur'); }, 10 ); } @@ -2390,7 +2390,7 @@ define([ var picker = this; setTimeout(function() { picker.toggle(); - self.$el.find('input').first().blur(); + self.$el.find('input').first().trigger('blur'); }, 10); } }, diff --git a/web/pgadmin/static/js/backgrid.pgadmin.js b/web/pgadmin/static/js/backgrid.pgadmin.js index eb4516aa4..2e87fbf27 100644 --- a/web/pgadmin/static/js/backgrid.pgadmin.js +++ b/web/pgadmin/static/js/backgrid.pgadmin.js @@ -348,7 +348,7 @@ define([ this.$el.html(''); this.delegateEvents(); if (this.grabFocus) - this.$el.focus(); + this.$el.trigger('focus'); return this; }, exitEditMode: function() { @@ -465,7 +465,7 @@ define([ enterEditMode: function() { this.$el.addClass('editor'); - $(this.$el.find('input')).focus(); + $(this.$el.find('input')).trigger('focus'); }, exitEditMode: function() { @@ -537,7 +537,7 @@ define([ }); self.model.trigger('backgrid:edited', self.model, self.column, command); - gotoCell.focus(); + gotoCell.trigger('focus'); } }, 20); } diff --git a/web/pgadmin/static/js/keyboard_shortcuts.js b/web/pgadmin/static/js/keyboard_shortcuts.js index 461945651..996a59192 100644 --- a/web/pgadmin/static/js/keyboard_shortcuts.js +++ b/web/pgadmin/static/js/keyboard_shortcuts.js @@ -84,7 +84,7 @@ function keyboardShortcutsDebugger($el, event, user_defined_shortcuts) { if(panel_content.length) { $input = $(panel_content).find('td.editable:first'); if($input.length) - $input.click(); + $input.trigger('click'); } } else if(this.validateShortcutKeys(next_panel_keys, event)) { this._stopEventPropagation(event); diff --git a/web/pgadmin/tools/backup/static/js/backup.js b/web/pgadmin/tools/backup/static/js/backup.js index 1b0b36286..94ab8b762 100644 --- a/web/pgadmin/tools/backup/static/js/backup.js +++ b/web/pgadmin/tools/backup/static/js/backup.js @@ -755,7 +755,7 @@ commonUtils }, error: function(xhr) { try { - var err = $.parseJSON(xhr.responseText); + var err = JSON.parse(xhr.responseText); alertify.alert( gettext('Backup job failed.'), err.errormsg @@ -1041,7 +1041,7 @@ commonUtils }, error: function(xhr) { try { - var err = $.parseJSON(xhr.responseText); + var err = JSON.parse(xhr.responseText); alertify.alert( gettext('Backup job failed.'), err.errormsg diff --git a/web/pgadmin/tools/datagrid/static/js/datagrid.js b/web/pgadmin/tools/datagrid/static/js/datagrid.js index b0ed60f6d..42122ed8e 100644 --- a/web/pgadmin/tools/datagrid/static/js/datagrid.js +++ b/web/pgadmin/tools/datagrid/static/js/datagrid.js @@ -473,7 +473,7 @@ define('pgadmin.datagrid', [ } try { - var err = $.parseJSON(xhr.responseText); + var err = JSON.parse(xhr.responseText); alertify.alert(gettext('Query Tool Initialize Error'), err.errormsg ); diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html index 26ef744a7..ad090262b 100644 --- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html +++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html @@ -222,7 +222,7 @@
- ' + + '' + + '
' + ); + }); + + afterEach(function () { + $('body').remove('#test-id'); }); describe('before the backend request', () => { @@ -1108,15 +1117,15 @@ describe('ExecuteQuery', () => { }); it('disables the run query button', () => { - const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-flash'); + let buttonFlash = $('#btn-flash'); - expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true); + expect(buttonFlash.prop('disabled')).toEqual(true); }); it('enable the cancel query button', () => { - const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query'); + let buttonFlash = $('#btn-cancel-query'); - expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', false); + expect(buttonFlash.prop('disabled')).toEqual(false); }); it('disable the query tool buttons', () => { @@ -1235,9 +1244,9 @@ describe('ExecuteQuery', () => { it('disable the cancel query button', (done) => { setTimeout(() => { - const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query'); + let buttonFlash = $('#btn-cancel-query'); - expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true); + expect(buttonFlash.prop('disabled')).toEqual(true); done(); }, 0); }); @@ -1355,9 +1364,9 @@ describe('ExecuteQuery', () => { it('should disable the cancel button', (done) => { setTimeout( () => { - const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query'); + let buttonFlash = $('#btn-cancel-query'); - expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true); + expect(buttonFlash.prop('disabled')).toEqual(true); done(); }, 0); }); @@ -1413,9 +1422,9 @@ describe('ExecuteQuery', () => { it('should disable the cancel button', (done) => { setTimeout( () => { - const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query'); + let buttonFlash = $('#btn-cancel-query'); - expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true); + expect(buttonFlash.prop('disabled')).toEqual(true); done(); }, 0); }); @@ -1481,9 +1490,9 @@ describe('ExecuteQuery', () => { it('should disable the cancel button', (done) => { setTimeout( () => { - const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query'); + let buttonFlash = $('#btn-cancel-query'); - expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true); + expect(buttonFlash.prop('disabled')).toEqual(true); done(); }, 0); }); @@ -1552,9 +1561,9 @@ describe('ExecuteQuery', () => { it('should disable the cancel button', (done) => { setTimeout( () => { - const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query'); + let buttonFlash = $('#btn-cancel-query'); - expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true); + expect(buttonFlash.prop('disabled')).toEqual(true); done(); }, 0); }); @@ -1626,9 +1635,9 @@ describe('ExecuteQuery', () => { it('should disable the cancel button', (done) => { setTimeout( () => { - const callToProp = findJQueryCallWithSelector(jqueryPropSpy, '#btn-cancel-query'); + let buttonFlash = $('#btn-cancel-query'); - expect(callToProp).jQuerytoHaveBeenCalledWith('disabled', true); + expect(buttonFlash.prop('disabled')).toEqual(true); done(); }, 0); }); @@ -1682,43 +1691,5 @@ describe('ExecuteQuery', () => { }); }); - - let findJQueryCallWithSelector = (jquerySpy, selector) => { - let result = undefined; - - jquerySpy.calls.all().forEach((call) => { - if (call.object.selector === selector) { - result = call; - } - }); - return result; - }; }); -const jQuerytoHaveBeenCalledWith = function (util) { - return { - compare: function (actual) { - let result = {}; - let expectedArgs = jasmine.util.argsToArray(arguments).slice(1); - if (actual.object === undefined || actual.object.selector === undefined) { - throw new Error('Expected a JQuery object, but got ' + jasmine.pp(actual) + '.'); - } - - result.pass = util.equals(actual.args, expectedArgs, ''); - if (result.pass) { - result.message = 'larifo'; - } else { - result.message = - 'Expected jquery with selector "' + - actual.object.selector + - '" to have been called with ' + - jasmine.pp(expectedArgs) + - ' but was called with ' + - jasmine.pp(actual.args); - } - - return result; - }, - }; -}; - diff --git a/web/yarn.lock b/web/yarn.lock index f5c893e73..39527992e 100644 --- a/web/yarn.lock +++ b/web/yarn.lock @@ -5327,14 +5327,10 @@ jquery-ui@>=1.8.0, jquery-ui@^1.12.1: version "1.12.1" resolved "https://registry.yarnpkg.com/jquery-ui/-/jquery-ui-1.12.1.tgz#bcb4045c8dd0539c134bc1488cdd3e768a7a9e51" -"jquery@>=1.7.1 <4.0.0", jquery@>=1.8.0, "jquery@^1.8.3 || ^2.0 || ^3.0", jquery@^3.3.1: +jquery@3.3.1, "jquery@>=1.7.1 <4.0.0", jquery@>=1.8.0, "jquery@^1.8.3 || ^2.0 || ^3.0", jquery@^3.3.1: version "3.3.1" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca" -jquery@^1.12.4: - version "1.12.4" - resolved "https://registry.yarnpkg.com/jquery/-/jquery-1.12.4.tgz#01e1dfba290fe73deba77ceeacb0f9ba2fec9e0c" - js-base64@^2.1.8, js-base64@^2.1.9: version "2.4.3" resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.3.tgz#2e545ec2b0f2957f41356510205214e98fad6582"