Commit 36b91385 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

resize handler had issues

parent 61c6f714
Pipeline #17314 passed with stage
in 18 minutes and 28 seconds
......@@ -14,6 +14,8 @@ minerva (14.0.5) stable; urgency=medium
* Bug fix: exported sbml file always contain model identifier (#1013)
* Bug fix: typo allel reverted to allele in overlay data (regression 14.0.0,
#1012)
* Bug fix: after loading/removing too many plugins it was impossible to load
new plugins (#1011)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 02 Dec 2019 16:00:00 +0200
......
......@@ -33,7 +33,6 @@ function PluginManager(options) {
*/
self._plugins = [];
self._pluginOnResizeHandlers = {};
self.registerListenerType("onResize");
self.addListener("onResize", function () {
......@@ -79,6 +78,13 @@ PluginManager.prototype.addPlugin = function (options) {
$(self.getElement()).show();
if (self._panels === undefined) {
self.getGuiUtils().initTabContent(self);
self._adjustHeight = function () {
var tabs = $(".parentTabs > .tab-content > .tab-pane", self.getElement());
if (tabs.length > 0) {
tabs.css('height', 'calc( 100vh - ' + $(".parentTabs > .tab-content", self.getElement()).offset().top + 'px )');
}
};
GuiConnector.addWindowResizeEvent(self._adjustHeight);
}
var element = Functions.createElement({type: "div"});
......@@ -113,29 +119,19 @@ PluginManager.prototype.addPlugin = function (options) {
}
return plugin.load();
}).then(function () {
$("a[href='#" + element.parentNode.id + "']", $(self.getElement()))[0].innerHTML = plugin.getName();
var tab = $(element.parentNode);
var adjustHeight = function () {
tab.css('height', 'calc( 100vh - ' + $(element.parentNode.parentNode).offset().top + 'px )');
};
self._pluginOnResizeHandlers[plugin.getPluginId()] = adjustHeight;
GuiConnector.addWindowResizeEvent(adjustHeight);
adjustHeight();
if ($(self.getElement()).width() < plugin.getDefaultWidth()) {
$(self.getElement()).css('flex', "0 0 " + plugin.getDefaultWidth() + "px");
$("a[href='#" + element.parentNode.id + "']", $(self.getElement()))[0].innerHTML = plugin.getName();
if ($(self.getElement()).width() < plugin.getDefaultWidth()) {
$(self.getElement()).css('flex', "0 0 " + plugin.getDefaultWidth() + "px");
}
self._adjustHeight();
return self.adjustMinWidth();
}
return self.adjustMinWidth();
}).then(function () {
).then(function () {
var newLinkHeight = $(".nav-tabs", self.getElement()).height();
if (self._plugins.length === 1) {
return self.getMap().getMapCanvas().triggerListeners("resize");
} else if (oldLinkHeight !== newLinkHeight) {
for (var key in self._pluginOnResizeHandlers) {
if (self._pluginOnResizeHandlers.hasOwnProperty(key)) {
self._pluginOnResizeHandlers[key]();
}
}
return self.getMap().getMapCanvas().triggerListeners("resize");
}
}).then(function () {
GuiConnector.setUrlParam("plugins", self._getLoadedPluginsAsHashList());
......@@ -145,7 +141,8 @@ PluginManager.prototype.addPlugin = function (options) {
GuiConnector.alert("Problem with loading plugin:<br/>" + e.message);
});
});
};
}
;
/**
*
......@@ -218,13 +215,13 @@ PluginManager.prototype.removePlugin = function (plugin) {
if (!found) {
return Promise.reject(new Error("Plugin not registered"));
}
GuiConnector.removeWindowResizeEvent(self._pluginOnResizeHandlers[plugin.getPluginId()]);
return plugin.unload().then(function () {
GuiConnector.setUrlParam("plugins", self._getLoadedPluginsAsHashList());
if (self._plugins.length === 0) {
$(self.getElement()).hide();
return self.getMap().getMapCanvas().triggerListeners("resize");
} else {
self._adjustHeight();
return self.adjustMinWidth();
}
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment