Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WEBUI: grid add - fix dialog center
  • Loading branch information
perexg committed Nov 21, 2015
1 parent f362fd1 commit 00ab005
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
23 changes: 17 additions & 6 deletions src/webui/static/app/extensions.js
Expand Up @@ -1771,15 +1771,11 @@ Ext.ux.Window = Ext.extend(Ext.Window, {
var ah = Ext.lib.Dom.getViewHeight();
var c = 0;

if (w > 200 && this.originalWidth === 0)
this.originalWidth = w;
else if (resize && this.originalWidth) {
if (resize && this.originalWidth) {
w = this.originalWidth;
c = 1;
}
if (h > 100 && this.originalHeight === 0)
this.originalHeight = h;
else if (resize && this.originalHeight) {
if (resize && this.originalHeight) {
h = this.originalHeight;
c = 1;
}
Expand All @@ -1801,10 +1797,25 @@ Ext.ux.Window = Ext.extend(Ext.Window, {
this.center();
} else if (resize) {
this.center();
} else {
return false;
}
return true;
},

setOriginSize : function(force) {
var w = this.getWidth();
var h = this.getHeight();
if (w > 200 && (force || this.originalWidth === 0))
this.originalWidth = w;
if (h > 100 && (force || this.originalHeight === 0))
this.originalHeight = h;
if (force && this.keepItVisible() === false)
this.center();
},

onShow : function() {
this.setOriginSize(false);
this.keepItVisible();
},

Expand Down
21 changes: 12 additions & 9 deletions src/webui/static/app/idnode.js
Expand Up @@ -921,6 +921,15 @@ tvheadend.idnode_editor = function(item, conf)

/* Buttons */
if (!conf.noButtons) {
if (conf.cancel) {
var cancelBtn = new Ext.Button({
text: _('Cancel'),
iconCls: 'cancel',
handler: conf.cancel
});
buttons.push(cancelBtn);
}

var saveBtn = new Ext.Button({
text: _('Save'),
iconCls: 'save',
Expand All @@ -941,15 +950,6 @@ tvheadend.idnode_editor = function(item, conf)
});
buttons.push(saveBtn);

if (conf.cancel) {
var cancelBtn = new Ext.Button({
text: _('Cancel'),
iconCls: 'cancel',
handler: conf.cancel
});
buttons.push(cancelBtn);
}

if (conf.help) {
var helpBtn = new Ext.Button({
text: _('Help'),
Expand Down Expand Up @@ -993,6 +993,7 @@ tvheadend.idnode_create = function(conf, onlyDefault)
{
var puuid = null;
var panel = null;
var win = null;
var pclass = null;

/* Buttons */
Expand Down Expand Up @@ -1079,6 +1080,7 @@ tvheadend.idnode_create = function(conf, onlyDefault)
panel.remove(s);
tvheadend.idnode_editor_form(d, null, panel, { create: true, showpwd: true });
saveBtn.setVisible(true);
win.setOriginSize(true);
}
}
};
Expand All @@ -1094,6 +1096,7 @@ tvheadend.idnode_create = function(conf, onlyDefault)
d = json_decode(d);
tvheadend.idnode_editor_form(d.props, d, panel, { create: true, showpwd: true });
saveBtn.setVisible(true);
win.setOriginSize(true);
}
});
};
Expand Down

0 comments on commit 00ab005

Please sign in to comment.