Ensure the query tool will open properly under MS Edge.

This commit is contained in:
Murtuza Zabuawala 2018-04-10 11:09:59 +01:00 committed by Dave Page
parent 97cf58fdc8
commit f5e474e4ec
5 changed files with 47 additions and 25 deletions

View File

@ -688,8 +688,8 @@ define('pgadmin.browser', [
success: function(res) { success: function(res) {
self.preferences_cache = res; self.preferences_cache = res;
pgBrowser.keyboardNavigation.init(); pgBrowser.keyboardNavigation.init();
modifyAnimation.modify_acitree_animation(self); modifyAnimation.modifyAcitreeAnimation(self);
modifyAnimation.modify_alertify_animation(self); modifyAnimation.modifyAlertifyAnimation(self);
}, },
error: function(xhr) { error: function(xhr) {
try { try {

View File

@ -387,7 +387,7 @@ define('pgadmin.preferences', [
view: {duration: 75}, view: {duration: 75},
}); });
modifyAnimation.modify_acitree_animation(pgBrowser, jTree.aciTree('api')); modifyAnimation.modifyAcitreeAnimation(pgBrowser, jTree.aciTree('api'));
this.show(); this.show();
}, },

View File

@ -10,13 +10,24 @@
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; 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)) { if (_.isUndefined(tree)) {
tree = pgBrowser.tree; tree = pgBrowser.tree;
} }
var enable_acitree_animation = pgBrowser.get_preference('browser',
'enable_acitree_animation').value; if(enableAcitreeAnimation) {
if(enable_acitree_animation == true) {
tree.options({ tree.options({
animateRoot: true, animateRoot: true,
unanimated: false, unanimated: false,
@ -35,23 +46,33 @@ function modify_acitree_animation(pgBrowser, tree) {
} }
} }
function modify_alertify_animation(pgBrowser) { function modifyAlertifyAnimation(pgBrowser) {
var enable_alertify_animation = pgBrowser.get_preference('browser', if(_.isUndefined(pgBrowser) || _.isNull(pgBrowser)) {
'enable_alertify_animation').value; pgBrowser = getBrowserInstance();
if(enable_alertify_animation == true) { }
$(document).find('link#alertify-no-animation').attr('disabled', 'disabled');
_.each(document.getElementsByTagName('iframe'), function(frame){ let enableAcitreeAnimation = pgBrowser.get_preference(
$(frame.contentDocument).find('link#alertify-no-animation').attr('disabled', 'disabled'); '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 { } else {
$(document).find('link#alertify-no-animation').removeAttr('disabled', 'disabled'); $(document).find('link#alertify-no-animation')
_.each(document.getElementsByTagName('iframe'), function(frame){ .removeAttr('disabled', 'disabled');
$(frame.contentDocument).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 = { module.exports = {
modify_acitree_animation : modify_acitree_animation, modifyAcitreeAnimation : modifyAcitreeAnimation,
modify_alertify_animation: modify_alertify_animation, modifyAlertifyAnimation: modifyAlertifyAnimation,
}; };

View File

@ -1727,6 +1727,9 @@ define('tools.querytool', [
var self = this; var self = this;
this.container = container; this.container = container;
this.state = {}; this.state = {};
// Disable animation first
modifyAnimation.modifyAlertifyAnimation();
if (!alertify.dlgGetServerPass) { if (!alertify.dlgGetServerPass) {
alertify.dialog('dlgGetServerPass', function factory() { alertify.dialog('dlgGetServerPass', function factory() {
return { return {
@ -3833,8 +3836,6 @@ define('tools.querytool', [
pgAdmin.SqlEditor = { pgAdmin.SqlEditor = {
// This function is used to create and return the object of grid controller. // This function is used to create and return the object of grid controller.
create: function(container) { 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); return new SqlEditorController(container);
}, },
jquery: $, jquery: $,

View File

@ -32,7 +32,7 @@ describe('modifyAnimation', function () {
describe('When browser tree animation is disabled', () => { describe('When browser tree animation is disabled', () => {
beforeEach(() => { beforeEach(() => {
pgBrowser.get_preference.and.returnValue({value: false}); pgBrowser.get_preference.and.returnValue({value: false});
modifyAnimation.modify_acitree_animation(pgBrowser); modifyAnimation.modifyAcitreeAnimation(pgBrowser);
}); });
it('tree options to animate should be disabled', function() { it('tree options to animate should be disabled', function() {
expect(pgBrowser.get_preference).toHaveBeenCalled(); expect(pgBrowser.get_preference).toHaveBeenCalled();
@ -50,7 +50,7 @@ describe('modifyAnimation', function () {
describe('When browser tree animation is enabled', () => { describe('When browser tree animation is enabled', () => {
beforeEach(() => { beforeEach(() => {
pgBrowser.get_preference.and.returnValue({value: true}); pgBrowser.get_preference.and.returnValue({value: true});
modifyAnimation.modify_acitree_animation(pgBrowser); modifyAnimation.modifyAcitreeAnimation(pgBrowser);
}); });
it('tree options to animate should be enabled', function() { it('tree options to animate should be enabled', function() {
expect(pgBrowser.get_preference).toHaveBeenCalled(); expect(pgBrowser.get_preference).toHaveBeenCalled();
@ -68,7 +68,7 @@ describe('modifyAnimation', function () {
describe('When alertify animation is disabled', () => { describe('When alertify animation is disabled', () => {
beforeEach(() => { beforeEach(() => {
pgBrowser.get_preference.and.returnValue({value: false}); pgBrowser.get_preference.and.returnValue({value: false});
modifyAnimation.modify_alertify_animation(pgBrowser); modifyAnimation.modifyAlertifyAnimation(pgBrowser);
}); });
it('alertify disalogue/notification animation should be disabled', function() { it('alertify disalogue/notification animation should be disabled', function() {
@ -81,7 +81,7 @@ describe('modifyAnimation', function () {
describe('When alertify animation is enabled', () => { describe('When alertify animation is enabled', () => {
beforeEach(() => { beforeEach(() => {
pgBrowser.get_preference.and.returnValue({value: true}); pgBrowser.get_preference.and.returnValue({value: true});
modifyAnimation.modify_alertify_animation(pgBrowser); modifyAnimation.modifyAlertifyAnimation(pgBrowser);
}); });
it('alertify disalogue/notification animation should be enabled', function() { it('alertify disalogue/notification animation should be enabled', function() {
expect(pgBrowser.get_preference).toHaveBeenCalled(); expect(pgBrowser.get_preference).toHaveBeenCalled();