diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index 0f640a906..897d27086 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -688,8 +688,8 @@ define('pgadmin.browser', [ success: function(res) { self.preferences_cache = res; pgBrowser.keyboardNavigation.init(); - modifyAnimation.modify_acitree_animation(self); - modifyAnimation.modify_alertify_animation(self); + modifyAnimation.modifyAcitreeAnimation(self); + modifyAnimation.modifyAlertifyAnimation(self); }, error: function(xhr) { try { diff --git a/web/pgadmin/preferences/static/js/preferences.js b/web/pgadmin/preferences/static/js/preferences.js index 8cea92208..cdbda0cd8 100644 --- a/web/pgadmin/preferences/static/js/preferences.js +++ b/web/pgadmin/preferences/static/js/preferences.js @@ -387,7 +387,7 @@ define('pgadmin.preferences', [ view: {duration: 75}, }); - modifyAnimation.modify_acitree_animation(pgBrowser, jTree.aciTree('api')); + modifyAnimation.modifyAcitreeAnimation(pgBrowser, jTree.aciTree('api')); this.show(); }, diff --git a/web/pgadmin/static/js/modify_animation.js b/web/pgadmin/static/js/modify_animation.js index 2e04c11c9..45315329a 100644 --- a/web/pgadmin/static/js/modify_animation.js +++ b/web/pgadmin/static/js/modify_animation.js @@ -10,13 +10,24 @@ import $ from 'jquery'; import _ from 'underscore'; -function modify_acitree_animation(pgBrowser, tree) { +function getBrowserInstance() { + if (!_.isUndefined(window.opener) && !_.isNull(window.opener)) { + return window.opener.pgAdmin.Browser; + } else { + return window.parent.pgAdmin.Browser; + } +} + +function modifyAcitreeAnimation(pgBrowser, tree) { + let enableAcitreeAnimation = pgBrowser.get_preference( + 'browser', 'enable_acitree_animation' + ).value; + if (_.isUndefined(tree)) { tree = pgBrowser.tree; } - var enable_acitree_animation = pgBrowser.get_preference('browser', - 'enable_acitree_animation').value; - if(enable_acitree_animation == true) { + + if(enableAcitreeAnimation) { tree.options({ animateRoot: true, unanimated: false, @@ -35,23 +46,33 @@ function modify_acitree_animation(pgBrowser, tree) { } } -function modify_alertify_animation(pgBrowser) { - var enable_alertify_animation = pgBrowser.get_preference('browser', - 'enable_alertify_animation').value; - if(enable_alertify_animation == true) { - $(document).find('link#alertify-no-animation').attr('disabled', 'disabled'); - _.each(document.getElementsByTagName('iframe'), function(frame){ - $(frame.contentDocument).find('link#alertify-no-animation').attr('disabled', 'disabled'); +function modifyAlertifyAnimation(pgBrowser) { + if(_.isUndefined(pgBrowser) || _.isNull(pgBrowser)) { + pgBrowser = getBrowserInstance(); + } + + let enableAcitreeAnimation = pgBrowser.get_preference( + 'browser', 'enable_alertify_animation' + ).value; + + if(enableAcitreeAnimation) { + $(document).find('link#alertify-no-animation') + .attr('disabled', 'disabled'); + _.each(document.getElementsByTagName('iframe'), function(frame) { + $(frame.contentDocument).find('link#alertify-no-animation') + .attr('disabled', 'disabled'); }); } else { - $(document).find('link#alertify-no-animation').removeAttr('disabled', 'disabled'); - _.each(document.getElementsByTagName('iframe'), function(frame){ - $(frame.contentDocument).find('link#alertify-no-animation').removeAttr('disabled', 'disabled'); + $(document).find('link#alertify-no-animation') + .removeAttr('disabled', 'disabled'); + _.each(document.getElementsByTagName('iframe'), function(frame) { + $(frame.contentDocument).find('link#alertify-no-animation') + .removeAttr('disabled', 'disabled'); }); } } module.exports = { - modify_acitree_animation : modify_acitree_animation, - modify_alertify_animation: modify_alertify_animation, + modifyAcitreeAnimation : modifyAcitreeAnimation, + modifyAlertifyAnimation: modifyAlertifyAnimation, }; diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index f8cb05af0..49e41b369 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -1727,6 +1727,9 @@ define('tools.querytool', [ var self = this; this.container = container; this.state = {}; + // Disable animation first + modifyAnimation.modifyAlertifyAnimation(); + if (!alertify.dlgGetServerPass) { alertify.dialog('dlgGetServerPass', function factory() { return { @@ -3833,8 +3836,6 @@ define('tools.querytool', [ pgAdmin.SqlEditor = { // This function is used to create and return the object of grid controller. create: function(container) { - var browser = (!_.isNull(window.opener)) ? window.opener.pgAdmin.Browser:window.parent.pgAdmin.Browser; - modifyAnimation.modify_alertify_animation(browser); return new SqlEditorController(container); }, jquery: $, diff --git a/web/regression/javascript/browser/modify_animation_spec.js b/web/regression/javascript/browser/modify_animation_spec.js index b47057fb1..b8060eed0 100644 --- a/web/regression/javascript/browser/modify_animation_spec.js +++ b/web/regression/javascript/browser/modify_animation_spec.js @@ -32,7 +32,7 @@ describe('modifyAnimation', function () { describe('When browser tree animation is disabled', () => { beforeEach(() => { pgBrowser.get_preference.and.returnValue({value: false}); - modifyAnimation.modify_acitree_animation(pgBrowser); + modifyAnimation.modifyAcitreeAnimation(pgBrowser); }); it('tree options to animate should be disabled', function() { expect(pgBrowser.get_preference).toHaveBeenCalled(); @@ -50,7 +50,7 @@ describe('modifyAnimation', function () { describe('When browser tree animation is enabled', () => { beforeEach(() => { pgBrowser.get_preference.and.returnValue({value: true}); - modifyAnimation.modify_acitree_animation(pgBrowser); + modifyAnimation.modifyAcitreeAnimation(pgBrowser); }); it('tree options to animate should be enabled', function() { expect(pgBrowser.get_preference).toHaveBeenCalled(); @@ -68,7 +68,7 @@ describe('modifyAnimation', function () { describe('When alertify animation is disabled', () => { beforeEach(() => { pgBrowser.get_preference.and.returnValue({value: false}); - modifyAnimation.modify_alertify_animation(pgBrowser); + modifyAnimation.modifyAlertifyAnimation(pgBrowser); }); it('alertify disalogue/notification animation should be disabled', function() { @@ -81,7 +81,7 @@ describe('modifyAnimation', function () { describe('When alertify animation is enabled', () => { beforeEach(() => { pgBrowser.get_preference.and.returnValue({value: true}); - modifyAnimation.modify_alertify_animation(pgBrowser); + modifyAnimation.modifyAlertifyAnimation(pgBrowser); }); it('alertify disalogue/notification animation should be enabled', function() { expect(pgBrowser.get_preference).toHaveBeenCalled();