Allow to specify the height & width from the javascript modules of an
individual node.pull/3/head
parent
238da58732
commit
875e251359
|
@ -29,3 +29,4 @@ backgrid-paginator 03632df MIT https://github.com/wyuenho/backgrid
|
|||
backgrid-select-all 1a00053 MIT https://github.com/wyuenho/backgrid-select-all
|
||||
dropzone 4e20bd4 MIT https://github.com/enyo/dropzone
|
||||
Filemanager 7e060c2 MIT https://github.com/simogeo/Filemanager
|
||||
Unit (Length) d8e6237 MIT https://github.com/heygrady/Units/blob/master/Length.min.js
|
||||
|
|
|
@ -27,6 +27,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
|||
sqlCreateHelp: 'sql-createtable.html',
|
||||
parent_type: ['schema', 'catalog'],
|
||||
hasScriptTypes: ['create', 'select', 'insert', 'update', 'delete'],
|
||||
height: '95%',
|
||||
width: '85%',
|
||||
Init: function() {
|
||||
/* Avoid mulitple registration of menus */
|
||||
if (this.initialized)
|
||||
|
|
|
@ -8,6 +8,8 @@ function($, _, pgAdmin, Backbone) {
|
|||
type: 'server-group',
|
||||
dialogHelp: '{{ url_for('help.static', filename='server_group_dialog.html') }}',
|
||||
label: '{{ _('Server Group') }}',
|
||||
width: '350px',
|
||||
height: '250px',
|
||||
Init: function() {
|
||||
/* Avoid multiple registration of menus */
|
||||
if (this.initialized)
|
||||
|
|
|
@ -355,7 +355,31 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
|
|||
return (_.indexOf(self.parent_type, d._type) != -1);
|
||||
} : function(d) {
|
||||
return (self.parent_type == d._type);
|
||||
});
|
||||
}),
|
||||
addPanel = function() {
|
||||
var d = window.document,
|
||||
b = d.body,
|
||||
el = d.createElement('div');
|
||||
|
||||
d.body.insertBefore(el, d.body.firstChild);
|
||||
|
||||
var pW = screen.width < 800 ? '95%' : '70%',
|
||||
pH = screen.height < 600 ? '95%' : '70%';
|
||||
w = pgAdmin.toPx(el, self.width || pW, 'width', true),
|
||||
h = pgAdmin.toPx(el, self.height|| pH, 'height', true),
|
||||
x = (b.offsetWidth - w) / 2,
|
||||
y = (b.offsetHeight - h) / 2;
|
||||
|
||||
p = pgBrowser.docker.addPanel(
|
||||
'node_props', wcDocker.DOCK.FLOAT, undefined,
|
||||
{w: w + 'px', h: h + 'px', x: x + 'px', y: y + 'px'}
|
||||
);
|
||||
|
||||
b.removeChild(el);
|
||||
delete(el);
|
||||
|
||||
return p;
|
||||
};
|
||||
|
||||
if (args.action == 'create') {
|
||||
// If we've parent, we will get the information of it for
|
||||
|
@ -401,15 +425,8 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
|
|||
|
||||
l = S('{{ _("Create - %%s") }}').sprintf(
|
||||
[this.label]).value();
|
||||
p = pgBrowser.docker.addPanel('node_props',
|
||||
wcDocker.DOCK.FLOAT, undefined, {
|
||||
w: (screen.width < 700 ?
|
||||
screen.width * 0.95 : screen.width * 0.5),
|
||||
h: (screen.height < 500 ?
|
||||
screen.height * 0.95 : screen.height * 0.5),
|
||||
x: (screen.width < 700 ? '2%' : '25%'),
|
||||
y: (screen.height < 500 ? '2%' : '25%')
|
||||
});
|
||||
p = addPanel();
|
||||
|
||||
setTimeout(function() {
|
||||
o.showProperties(i, d, p, args.action);
|
||||
}, 10);
|
||||
|
@ -443,17 +460,8 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
|
|||
}, 10);
|
||||
}
|
||||
} else {
|
||||
p = pgBrowser.docker.addPanel('node_props',
|
||||
wcDocker.DOCK.FLOAT, undefined, {
|
||||
w: (screen.width < 700 ?
|
||||
screen.width * 0.95 : screen.width * 0.5),
|
||||
h: (screen.height < 500 ?
|
||||
screen.height * 0.95 : screen.height * 0.5),
|
||||
x: (screen.width < 700 ? '2%' : '25%'),
|
||||
y: (screen.height < 500 ? '2%' : '25%')
|
||||
});
|
||||
pgBrowser.Node.panels = pgBrowser.Node.panels || {};
|
||||
pgBrowser.Node.panels[d.id] = p;
|
||||
p = pgBrowser.Node.panels[d.id] = addPanel();
|
||||
|
||||
setTimeout(function() {
|
||||
o.showProperties(i, d, p, args.action);
|
||||
|
|
|
@ -12,5 +12,10 @@
|
|||
}(function(){
|
||||
var pgAdmin = window.pgAdmin = window.pgAdmin || {};
|
||||
|
||||
// Reference:
|
||||
// https://github.com/heygrady/Units/blob/master/Length.min.js
|
||||
// Changed it to save the function in pgAdmin object.
|
||||
(function(t,e,o) {"use strict";function r(t,e,r,p){r=r||"width";var n,l,m,c=(e.match(s)||[])[2],f="px"===c?1:d[c+"toPx"],u=/r?em/i;if(f||u.test(c)&&!p)t=f?t:"rem"===c?i:"fontSize"===r?t.parentNode||t:t,f=f||parseFloat(a(t,"fontSize")),m=parseFloat(e)*f;else{n=t.style,l=n[r];try{n[r]=e}catch(x){return 0}m=n[r]?parseFloat(a(t,r)):0,n[r]=l!==o?l:null}return m}function a(t,e){var o,n,i,l,d,c=/^top|bottom/,f=["paddingTop","paddingBottom","borderTop","borderBottom"],u=4;if(o=m?m(t)[e]:(n=t.style["pixel"+e.charAt(0).toUpperCase()+e.slice(1)])?n+"px":"fontSize"===e?r(t,"1em","left",1)+"px":t.currentStyle[e],i=(o.match(s)||[])[2],"%"===i&&p)if(c.test(e)){for(l=(d=t.parentNode||t).offsetHeight;u--;)l-=parseFloat(a(d,f[u]));o=parseFloat(o)/100*l+"px"}else o=r(t,o);else("auto"===o||i&&"px"!==i)&&m?o=0:i&&"px"!==i&&!m&&(o=r(t,o)+"px");return o}var p,n=e.createElement("test"),i=e.documentElement,l=e.defaultView,m=l&&l.getComputedStyle,s=/^(-?[\d+\.\-]+)([a-z]+|%)$/i,d={},c=[1/25.4,1/2.54,1/72,1/6],f=["mm","cm","pt","pc","in","mozmm"],u=6;for(i.appendChild(n),m&&(n.style.marginTop="1%",p="1%"===m(n).marginTop);u--;)d[f[u]+"toPx"]=c[u]?c[u]*d.inToPx:r(n,"1"+f[u]);i.removeChild(n),n=o,t.toPx=r})(pgAdmin, window.document);
|
||||
|
||||
return pgAdmin;
|
||||
}));
|
||||
|
|
Loading…
Reference in New Issue