Fix the properties toolbar at the top of the panel so it's always

visible.

This patch also introduce a callback 'onCreate' for each panel, and
frame, which will be called whenever a panel/frame is being created.
This commit is contained in:
Ashesh Vashi
2016-04-18 12:38:53 +05:30
parent 7522d89890
commit 9aee9794c1
5 changed files with 35 additions and 11 deletions

View File

@@ -7,7 +7,7 @@ function(_, pgAdmin) {
pgAdmin.Browser.Frame = function(options) {
var defaults = [
'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
'isPrivate', 'url', 'icon'];
'isPrivate', 'url', 'icon', 'onCreate'];
_.extend(this, _.pick(options, defaults));
}
@@ -23,6 +23,7 @@ function(_, pgAdmin) {
icon: '',
panel: null,
frame: null,
onCreate: null,
load: function(docker) {
var that = this;
if (!that.panel) {
@@ -85,6 +86,10 @@ function(_, pgAdmin) {
wcDocker.EVENT.SCROLLED], function(ev) {
myPanel.on(ev, that.eventFunc.bind(myPanel, ev));
});
if (that.onCreate && _.isFunction(that.onCreate)) {
that.onCreate.apply(that, [myPanel, frame, $container]);
}
}
});
}

View File

@@ -7,7 +7,7 @@ function(_, pgAdmin) {
pgAdmin.Browser.Panel = function(options) {
var defaults = [
'name', 'title', 'width', 'height', 'showTitle', 'isCloseable',
'isPrivate', 'content', 'icon', 'events'];
'isPrivate', 'content', 'icon', 'events', 'onCreate'];
_.extend(this, _.pick(options, defaults));
}
@@ -22,6 +22,7 @@ function(_, pgAdmin) {
content: '',
icon: '',
panel: null,
onCreate: null,
load: function(docker, title) {
var that = this;
if (!that.panel) {
@@ -40,13 +41,12 @@ function(_, pgAdmin) {
myPanel.icon(that.icon)
}
var $container = $('<div>', {
'class': 'pg-panel-content'
}).append($(that.content));
myPanel.closeable(!!that.isCloseable);
myPanel.layout().addItem(
$('<div>', {
'class': 'pg-panel-content'
})
.append($(that.content))
);
myPanel.layout().addItem($container);
that.panel = myPanel;
if (that.events && _.isObject(that.events)) {
_.each(that.events, function(v, k) {
@@ -67,6 +67,10 @@ function(_, pgAdmin) {
wcDocker.EVENT.SCROLLED], function(ev) {
myPanel.on(ev, that.eventFunc.bind(myPanel, ev));
});
if (that.onCreate && _.isFunction(that.onCreate)) {
that.onCreate.apply(that, [myPanel, $container]);
}
}
});
}