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) {
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 {

View File

@ -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();
},

View File

@ -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,
};

View File

@ -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: $,

View File

@ -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();