Skip to content

Commit

Permalink
Merge pull request #12 from jenkinsci/fix-log-placement
Browse files Browse the repository at this point in the history
Fix log popup placement [JENKINS-33109]
  • Loading branch information
svanoort committed May 10, 2016
2 parents c5c9c33 + 1c67a90 commit 18898e7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ui/src/main/js/view/stage-logs.js
Expand Up @@ -44,6 +44,8 @@ exports.render = function (stageDescription, onElement) {
onElement.on(clickNSEvent, function() {
dialog.show('Stage Logs (' + stageDescription.name + ')', stageLogsDom, {
classes: 'cbwf-stage-logs-dialog',
placement: 'window-visible-top',
onElement: onElement,
width: dialogWidth,
height: dialogHeight,
onshow: function() {
Expand Down
4 changes: 3 additions & 1 deletion ui/src/main/js/view/widgets/dialog/index.js
Expand Up @@ -59,7 +59,9 @@ exports.show = function(title, body, options) {
bodyEl.append(body);

options.modal = true;
var popover = popoverWidget.newPopover(title, dialog, undefined, options);
// Undefined for the onElement makes it in the window center, otherwise it needs it for positioning
var popover = popoverWidget.newPopover(title, dialog, options.onElement, options);

popover.show();
if (options.onshow) {
options.onshow();
Expand Down
14 changes: 14 additions & 0 deletions ui/src/main/js/view/widgets/popover/index.js
Expand Up @@ -343,6 +343,20 @@ Popover.prototype.applyPlacement = function() {
// top thn 1/4 the window height.
topPlacement = Math.min(topPlacement, (winWidth / 4));

thisPopover.popover.css({
'top': topPlacement,
'left': leftPlacement
});
} else if (placement === 'window-visible-top') { // Centered at top of visible window
var winWidth = $(theWindow).width();
var popoverWidth = thisPopover.popover.width();
var leftPlacement = ((winWidth - popoverWidth) / 2);

var topPlacement = 20; // For tests, which don't have a window
if (typeof window !== 'undefined') {
topPlacement = window.scrollY + 20;
}

thisPopover.popover.css({
'top': topPlacement,
'left': leftPlacement
Expand Down
6 changes: 3 additions & 3 deletions ui/src/test/js/util/formatters-spec.js
Expand Up @@ -17,9 +17,9 @@ describe("util/formatters-spec", function () {
expect(formatters.memory(1)).toBe('1B');
expect(formatters.memory(999)).toBe('999B');
expect(formatters.memory(1999)).toBe('1.95KB');
expect(formatters.memory(1999999)).toBe('1.95MB');
expect(formatters.memory(1999999999)).toBe('1.95GB');
expect(formatters.memory(1999999999999)).toBe('1.95TB');
expect(formatters.memory(1999999)).toBe('1.91MB');
expect(formatters.memory(1999999999)).toBe('1.86GB');
expect(formatters.memory(1999999999999)).toBe('1.82TB');
});

it("- test_time_default", function () {
Expand Down

0 comments on commit 18898e7

Please sign in to comment.