Skip to content

Commit e7ba730

Browse files
committed
new scopes panel instead of the grey bar
1 parent b0aafac commit e7ba730

File tree

6 files changed

+126
-81
lines changed

6 files changed

+126
-81
lines changed

src/org/opensolaris/opengrok/analysis/JFlexXref.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -345,19 +345,6 @@ public void write(Writer out) throws IOException {
345345
while (!stack.empty()) {
346346
yypop();
347347
}
348-
349-
writeScopesFooter();
350-
}
351-
352-
/**
353-
* Write a JavaScript function that display scopes panel if scopes are
354-
* available
355-
*/
356-
private void writeScopesFooter() throws IOException {
357-
//TODO try to get rid of included js scripts generated from here (all js should ideally be in util)
358-
if (scopesEnabled && scopes != null && scopes.size() > 0) {
359-
out.append("<script type=\"text/javascript\">document.getElementById(\"scope\").style.display = \"block\";</script>");
360-
}
361348
}
362349

363350
/**

web/default/style.css

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -814,14 +814,17 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bo
814814
display: none;
815815
}
816816

817-
.intelli-window {
817+
.window {
818818
position: absolute;
819-
width: 504px;
820-
max-height: 400px;
821-
overflow: auto;
822-
z-index: 10;
823819
font-size: 12px;
824820
font-family: monospace;
821+
overflow: auto;
822+
z-index: 10;
823+
}
824+
825+
.intelli-window {
826+
width: 504px;
827+
max-height: 400px;
825828
}
826829

827830
.symbol-highlighted {
@@ -830,13 +833,13 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bo
830833
}
831834

832835
.messages-window {
833-
position: absolute;
834836
width: 40%;
835837
max-height: 400px;
836-
overflow: auto;
837-
z-index: 10;
838-
font-size: 12px;
839-
font-family: monospace;
838+
}
839+
840+
.scopes-window {
841+
min-width: 150px;
842+
max-height: 400px;
840843
}
841844

842845
.important-note {
@@ -1069,16 +1072,6 @@ span.scope-signature {
10691072
display: none;
10701073
}
10711074

1072-
div#scope {
1073-
display: none;
1074-
min-height: 1em;
1075-
text-align: left;
1076-
background-color: #dddddd;
1077-
padding: 0.5em 0.5em 0.5em 6.5ex;
1078-
font-family: monospace;
1079-
font-weight: bold;
1080-
}
1081-
10821075
/** --------------- fold arrows for main page ------------ */
10831076

10841077
.fold-down:before {

web/js/utils.js

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@
550550
.append($controls)
551551

552552
$close.click(function () {
553-
$window.toggle()
553+
$window.hide()
554554
return false;
555555
});
556556

@@ -687,8 +687,6 @@
687687
this.init = function (options, context) {
688688
return $.intelliWindow = $window.create($.extend({
689689
title: 'Intelligence window',
690-
parent: undefined,
691-
draggable: true,
692690
selector: 'a.intelliWindow-symbol',
693691
google_url: 'https://www.google.com/search?q=',
694692
project: undefined,
@@ -942,7 +940,6 @@
942940
this.init = function (options, context) {
943941
return $.messagesWindow = $window.create(options = $.extend({
944942
title: 'Messages Window',
945-
parent: undefined,
946943
draggable: false,
947944
init: function ($window) {
948945
return $window
@@ -1001,6 +998,66 @@
1001998
$.messagesWindow = new ($.extend(messagesWindow, $.messagesWindow ? $.messagesWindow : {}));
1002999
})(window, document, jQuery, jQuery.window);
10031000

1001+
/**
1002+
* Scopes window plugin.
1003+
*
1004+
* @author Kryštof Tulinger
1005+
*/
1006+
(function (browserWindow, document, $, $window) {
1007+
if (!$window || typeof $window.create !== 'function') {
1008+
console.log("The scopesWindow plugin requires $.window plugin")
1009+
return;
1010+
}
1011+
1012+
var scopesWindow = function () {
1013+
this.init = function (options, context) {
1014+
return $.scopesWindow = $window.create($.extend({
1015+
title: 'Scopes Window',
1016+
draggable: false,
1017+
init: function ($window) {
1018+
return $window
1019+
.attr('id', 'scopes_win')
1020+
.addClass('scopes-window')
1021+
.addClass('diff_navigation_style')
1022+
.css({top: '150px', right: '20px'})
1023+
.append(this.$scopes = $("<div>"))
1024+
},
1025+
load: function ($window) {
1026+
$window.hide().css('top', parseFloat($("#content").css('top').replace('px', '')) + 10 + 'px')
1027+
1028+
// override the hide and show to throw an event
1029+
$.each(['hide', 'show'], function () {
1030+
var event = this
1031+
var old = $window[event];
1032+
$window[event] = function () {
1033+
return old.call($window).trigger(event);
1034+
}
1035+
});
1036+
},
1037+
update: function (data) {
1038+
if(!this.$window.is(':visible') && !this.$window.data('shown-once')) {
1039+
console.log(data)
1040+
this.$window.show().data('shown-once', true);
1041+
}
1042+
this.$scopes.empty()
1043+
this.$scopes.html(this.buildLink(data.id, data.link))
1044+
}
1045+
}, options || {}), $.extend({
1046+
$scopes: $(),
1047+
buildLink: function (href, name) {
1048+
return $('<a>').attr('href', '#' + href).attr('title', name).text(name)
1049+
}
1050+
}, context || {}));
1051+
}
1052+
}
1053+
$.scopesWindow = new ($.extend(scopesWindow, $.scopesWindow ? $.scopesWindow : {}));
1054+
})(window, document, jQuery, jQuery.window);
1055+
1056+
function init_scopes() {
1057+
$.scopesWindow.init();
1058+
$("#content").scroll(scope_on_scroll);
1059+
}
1060+
10041061
function init_results_autohide() {
10051062
$("#sbox input[type='submit']").click(function (e) {
10061063
$("#footer").not(".main_page").hide(); // footer
@@ -1126,7 +1183,9 @@ $(document).ready(function () {
11261183
* Initialize scope scroll event to display scope information correctly when
11271184
* the element comes into the viewport.
11281185
*/
1129-
$("#content").scroll(scope_on_scroll);
1186+
$('#src').each(function () {
1187+
init_scopes();
1188+
})
11301189

11311190
/**
11321191
* Initialize table sorter on every directory listing.
@@ -1501,6 +1560,23 @@ function lsttoggle() {
15011560

15021561
document.body.appendChild(document.sym_div);
15031562
document.sym_div_shown = 1;
1563+
1564+
if ($.scopesWindow.initialized) {
1565+
$.scopesWindow.on('show', function () {
1566+
document.sym_div_top = $.scopesWindow.offset().top + $.scopesWindow.outerHeight() + 20
1567+
document.sym_div.style.height = get_sym_div_height() + "px";
1568+
$(document.sym_div).css('top', $.scopesWindow.offset().top + $.scopesWindow.outerHeight() + 20);
1569+
}).on('hide', function () {
1570+
document.sym_div_top = 100
1571+
document.sym_div.style.height = get_sym_div_height() + "px";
1572+
$(document.sym_div).css('top', get_sym_div_top());
1573+
})
1574+
if ($.scopesWindow.is(':visible')) {
1575+
document.sym_div_top = $.scopesWindow.offset().top + $.scopesWindow.outerHeight() + 20
1576+
document.sym_div.style.height = get_sym_div_height() + "px";
1577+
$(document.sym_div).css('top', $.scopesWindow.offset().top + $.scopesWindow.outerHeight() + 20);
1578+
}
1579+
}
15041580
} else if (document.sym_div_shown == 1) {
15051581
document.sym_div.className = "sym_list_style_hide";
15061582
document.sym_div_shown = 0;
@@ -1676,7 +1752,6 @@ function fold(id) {
16761752
function scope_on_scroll() {
16771753
var cnt = document.getElementById("content");
16781754
var y = cnt.getBoundingClientRect().top + 2;
1679-
var $scope_cnt_el = $('#scope_content');
16801755
var c = document.elementFromPoint(15, y + 1);
16811756

16821757
if ($(c).is('.l, .hl')) {
@@ -1688,6 +1763,11 @@ function scope_on_scroll() {
16881763

16891764
var $head = $par.hasClass('scope-body') ? $par.prev() : $par;
16901765
var $sig = $head.children().first()
1691-
$scope_cnt_el.html('<a href="#' + $head.attr('id') + '">' + $sig.html() + '</a>');
1766+
if ($.scopesWindow.initialized) {
1767+
$.scopesWindow.update({
1768+
'id': $head.attr('id'),
1769+
'link': $sig.html(),
1770+
})
1771+
}
16921772
}
16931773
}

web/mast.jsp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ include file="pageheader.jspf"
192192
%>
193193
<input type="hidden" id="contextpath" value="<%=request.getContextPath()%>" />
194194
</div>
195-
<div id="scope"><span id="scope_content">&nbsp;</span></div>
196195
</form>
197196
</div>
198197
<div id="content">

web/offwhite/style.css

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -858,14 +858,17 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bo
858858
display: none;
859859
}
860860

861-
.intelli-window {
861+
.window {
862862
position: absolute;
863-
width: 504px;
864-
max-height: 400px;
865-
overflow: auto;
866-
z-index: 10;
867863
font-size: 12px;
868864
font-family: monospace;
865+
overflow: auto;
866+
z-index: 10;
867+
}
868+
869+
.intelli-window {
870+
width: 504px;
871+
max-height: 400px;
869872
}
870873

871874
.symbol-highlighted {
@@ -874,13 +877,13 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bo
874877
}
875878

876879
.messages-window {
877-
position: absolute;
878880
width: 40%;
879881
max-height: 400px;
880-
overflow: auto;
881-
z-index: 10;
882-
font-size: 12px;
883-
font-family: monospace;
882+
}
883+
884+
.scopes-window {
885+
min-width: 150px;
886+
max-height: 400px;
884887
}
885888

886889
.important-note {
@@ -1100,16 +1103,6 @@ span.scope-signature {
11001103
display: none;
11011104
}
11021105

1103-
div#scope {
1104-
display: none;
1105-
min-height: 1em;
1106-
text-align: left;
1107-
background-color: #e4e4c8;
1108-
padding: 0.5em 0.5em 0.5em 6.5ex;
1109-
font-family: monospace;
1110-
font-weight: bold;
1111-
}
1112-
11131106
/** --------------- fold arrows for main page ------------ */
11141107

11151108
.fold-down:before {

web/polished/style.css

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -914,14 +914,17 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bo
914914
display: none;
915915
}
916916

917-
.intelli-window {
917+
.window {
918918
position: absolute;
919-
width: 504px;
920-
max-height: 400px;
921-
overflow: auto;
922-
z-index: 10;
923919
font-size: 12px;
924920
font-family: monospace;
921+
overflow: auto;
922+
z-index: 10;
923+
}
924+
925+
.intelli-window {
926+
width: 504px;
927+
max-height: 400px;
925928
}
926929

927930
.symbol-highlighted {
@@ -930,13 +933,13 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bo
930933
}
931934

932935
.messages-window {
933-
position: absolute;
934936
width: 40%;
935937
max-height: 400px;
936-
overflow: auto;
937-
z-index: 10;
938-
font-size: 12px;
939-
font-family: monospace;
938+
}
939+
940+
.scopes-window {
941+
min-width: 150px;
942+
max-height: 400px;
940943
}
941944

942945
.important-note {
@@ -1178,16 +1181,6 @@ span.scope-signature {
11781181
display: none;
11791182
}
11801183

1181-
div#scope {
1182-
display: none;
1183-
min-height: 1em;
1184-
text-align: left;
1185-
background-color: #dddddd;
1186-
padding: 0.5em 0.5em 0.5em 6.5ex;
1187-
font-family: monospace;
1188-
font-weight: bold;
1189-
}
1190-
11911184
/** --------------- fold arrows for main page ------------ */
11921185

11931186
.fold-down:before {

0 commit comments

Comments
 (0)