Skip to content

Commit e5b1c0b

Browse files
authored
Merge pull request #1681 from tulinkry/window-fixed-header
fixed header for popup windows with scrollable content inside
2 parents 873a5de + bbc9705 commit e5b1c0b

File tree

4 files changed

+73
-25
lines changed

4 files changed

+73
-25
lines changed

src/org/opensolaris/opengrok/web/Scripts.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ public String toHtml() {
126126
SCRIPTS.put("jquery-tablesorter", new FileScript("js/jquery-tablesorter-2.26.6.min.js", 12));
127127
SCRIPTS.put("tablesorter-parsers", new FileScript("js/tablesorter-parsers-0.0.1.js", 13));
128128
SCRIPTS.put("searchable-option-list", new FileScript("js/searchable-option-list-2.0.5.min.js", 14));
129-
SCRIPTS.put("utils", new FileScript("js/utils-0.0.20.js", 15));
129+
SCRIPTS.put("utils", new FileScript("js/utils-0.0.21.js", 15));
130130
SCRIPTS.put("repos", new FileScript("js/repos-0.0.1.js", 20));
131-
SCRIPTS.put("diff", new FileScript("js/diff-0.0.2.js", 20));
131+
SCRIPTS.put("diff", new FileScript("js/diff-0.0.3.js", 20));
132132
}
133133

134134
/**

web/default/style.css

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -820,16 +820,6 @@ a.scope { /* scope */ color: steelblue; font-weight: bol
820820
margin-bottom: 1em;
821821
}
822822

823-
/* "Navigate Style" */
824-
.diff_navigation_style {
825-
border: solid 1px #c0c0c0;
826-
border-radius: 5px;
827-
box-shadow: 10px 10px 5px #888888;
828-
background-color: rgb(255,255,204);
829-
position: absolute;
830-
padding: 1em;
831-
}
832-
833823
/* "Tooltip Style (minor information)" */
834824
.tooltip {
835825
position: absolute;
@@ -841,10 +831,34 @@ a.scope { /* scope */ color: steelblue; font-weight: bol
841831
position: fixed;
842832
font-size: 12px;
843833
font-family: monospace;
844-
overflow: auto;
834+
overflow: hidden;
845835
z-index: 10;
846836
}
847837

838+
.window-header {
839+
padding: 10px;
840+
min-height: 20px;
841+
border-bottom: 1px solid black;
842+
}
843+
844+
.window-body {
845+
overflow: auto;
846+
height: calc(
847+
100% /* whole window */
848+
- 40px /* height of the header + its padding-top + padding-bottom */
849+
- 1px /* border of the header */
850+
- 20px /* padding-top + padding-bottom */
851+
);
852+
padding-left: 10px;
853+
padding-bottom: 10px;
854+
padding-right: 10px;
855+
padding-top: 10px;
856+
width: calc(
857+
100% /* whole window */
858+
- 20px /* padding-left + padding-right */
859+
);
860+
}
861+
848862
.intelli-window {
849863
width: 504px;
850864
max-height: 400px;
@@ -905,7 +919,6 @@ a.scope { /* scope */ color: steelblue; font-weight: bol
905919
border-radius: 5px;
906920
box-shadow: 10px 10px 5px #888888;
907921
background-color: rgb(255,255,204);
908-
padding: 1em;
909922
}
910923

911924
.diff_navigation {

web/js/diff-0.0.2.js renamed to web/js/diff-0.0.3.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@
119119
top: '150px',
120120
right: '20px',
121121
'min-width': '300px'})
122+
.body()
122123
.append($controls)
123124
.append(this.$summary)
124125
.append(this.$progress)
126+
.window()
125127
},
126128
load: function ($window) {
127129
var that = this

web/js/utils-0.0.20.js renamed to web/js/utils-0.0.21.js

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@
449449
* init: function ($window) {
450450
* // called when creating the new window
451451
* // you can modify the new window object - it's jquery object
452+
* // you must return the modified window object
452453
* },
453454
* load: function ($window) {
454455
* // called when the page is successfully loaded
@@ -478,6 +479,9 @@
478479
* $myWindow.move(position) to move the window to the given position
479480
* if no position is given it may be determined from the mouse position
480481
*
482+
* For custom content in the window you can use body() function:
483+
* $myWindow.body().append($('<div>').addClass('important-div'))
484+
*
481485
* @author Kryštof Tulinger
482486
*/
483487
(function (browserWindow, document, $, $script) {
@@ -596,30 +600,49 @@
596600
}
597601

598602
this.addCallback('init', function ($window) {
599-
var $top, $close, $controls
603+
var $top, $close, $controls, $header, $body;
600604

601605
$top = $("<div>").addClass('clearfix')
602606
.append($("<div>").addClass("pull-left").append($("<b>").text(this.options.title || "Window")))
603-
.append($close = $("<a href=\"#\" class=\"pull-right minimize\">x</a>"))
607+
.append($("<div>").addClass('pull-right').append($close = $("<a href=\"#\" class=\"minimize\">x</a>")))
608+
609+
$header = $("<div>").addClass('window-header')
610+
.append($top);
604611

605-
$controls = $('<div>')
606-
.addClass('clearfix')
612+
$body = $("<div>").addClass("window-body")
607613
.append(self.$errors = $('<div>').css('text-align', 'center'))
608614

609615
$window = $("<div>")
610616
.addClass('window')
611617
.addClass('diff_navigation_style')
612618
.css('z-index', 15000)
613619
.hide()
614-
.append($top)
615-
.append($("<hr>"))
616-
.append($controls)
620+
.append($header)
621+
.append($body);
617622

618623
$close.click(function () {
619624
$window.hide()
620625
return false;
621626
});
622627

628+
/**
629+
* Get the element for the window body.
630+
* This should be used to place your desired content.
631+
*
632+
* The returned object has a method {@code window()}
633+
* which returns the whole window.
634+
*
635+
* {@code $window} is equivalent to {@code $window.body().window()}
636+
*
637+
* @returns jQuery object of the window body
638+
*/
639+
$window.body = function () {
640+
$body.window = function () {
641+
return $window;
642+
}
643+
return $body;
644+
}
645+
623646
/**
624647
* Display custom error message in the window
625648
* @param {string} msg message
@@ -703,7 +726,7 @@
703726
that.clientY = e.clientY;
704727
})
705728
$(document).keyup(function (e) {
706-
var key = e.keyCode
729+
var key = e.keyCode;
707730
switch (key) {
708731
case 27: // esc
709732
that.$window.hide();
@@ -832,6 +855,7 @@
832855
return $window
833856
.attr('id', 'intelli_win')
834857
.addClass('intelli-window')
858+
.body()
835859
.append($controls)
836860
.append($("<h2>").addClass('symbol-name'))
837861
.append($("<span>").addClass('symbol-description'))
@@ -841,7 +865,8 @@
841865
.append($("<h5>").text("In project \"" + this.project + "\""))
842866
.append($secondList)
843867
.append($("<h5>").text("On Google"))
844-
.append($thirdList);
868+
.append($thirdList)
869+
.window();
845870
},
846871
load: function ($window) {
847872
var that = this;
@@ -1055,7 +1080,9 @@
10551080
.addClass('messages-window')
10561081
.addClass('diff_navigation_style')
10571082
.css({top: '150px', right: '20px'})
1083+
.body()
10581084
.append(this.$messages = $("<div>"))
1085+
.window();
10591086
},
10601087
load: function ($window) {
10611088
$window.mouseenter(function () {
@@ -1128,7 +1155,9 @@
11281155
.addClass('scopes-window')
11291156
.addClass('diff_navigation_style')
11301157
.css({top: '150px', right: '20px'})
1158+
.body()
11311159
.append(this.$scopes = $("<div>"))
1160+
.window();
11321161
},
11331162
load: function ($window) {
11341163
$window.hide().css('top', $("#content").offset().top + 10 + 'px')
@@ -1194,8 +1223,11 @@
11941223
.attr('id', 'navigate_win')
11951224
.addClass('navigate-window')
11961225
.addClass('diff_navigation_style')
1197-
.css({top: '150px', right: '20px'})
1226+
.addClass('diff_navigation_style')
1227+
.css({top: '150px', right: '20px', height: this.defaultHeight + 'px'})
1228+
.body()
11981229
.append(this.$content)
1230+
.window();
11991231
},
12001232
load: function ($window) {
12011233
var that = this
@@ -1254,6 +1286,7 @@
12541286
}, options || {
12551287
}), $.extend({
12561288
$content: $('<div>'),
1289+
defaultHeight: 480,
12571290
buildLink: function (href, name, c) {
12581291
return $('<a>').attr('href', '#' + href).attr('title', this.escapeHtml(name)).addClass(c).html(this.escapeHtml(name)).click(lnshow)
12591292
},
@@ -1278,7 +1311,7 @@
12781311
$.scopesWindow.is(':visible')) {
12791312
a.top = $.scopesWindow.position().top + $.scopesWindow.outerHeight() + 20;
12801313
}
1281-
a.height = Math.min(parseFloat($w.css('max-height')) || 480, $(browserWindow).outerHeight() - a.top - ($w.outerHeight(true) - $w.height()) - 20);
1314+
a.height = Math.min(parseFloat($w.css('max-height')) || this.defaultHeight, $(browserWindow).outerHeight() - a.top - ($w.outerHeight(true) - $w.height()) - 20);
12821315

12831316
if (a.height == $w.height() && a.top == this.getTopOffset())
12841317
return $w;

0 commit comments

Comments
 (0)