Skip to content

Commit

Permalink
introducing a project tunable to open navigate window by default (#1685)
Browse files Browse the repository at this point in the history
approaches #1636
  • Loading branch information
tulinkry authored and Vladimir Kotal committed Jul 24, 2017
1 parent 160fd27 commit 3ef7a06
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
30 changes: 29 additions & 1 deletion src/org/opensolaris/opengrok/configuration/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Serializable;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;

/**
* Placeholder for the information that builds up a project
*/
public class Project implements Comparable<Project>, Nameable {
public class Project implements Comparable<Project>, Nameable, Serializable {

private static final long serialVersionUID = 1L;

private String path;

Expand All @@ -48,6 +51,12 @@ public class Project implements Comparable<Project>, Nameable {
*/
private int tabSize;

/**
* A flag if the navigate window should be opened by default when browsing
* the source code of this project.
*/
private boolean navigateWindowEnabled = false;

/**
* This marks the project as (not)ready before initial index is done.
* this is to avoid all/multi-project searches referencing this project
Expand Down Expand Up @@ -165,6 +174,25 @@ public boolean hasTabSizeSetting() {
return tabSize > 0;
}

/**
* Indicate whether the navigate window should be opened by default when
* browsing a source code from this project.
*
* @return true if yes; false otherwise
*/
public boolean isNavigateWindowEnabled() {
return navigateWindowEnabled;
}

/**
* Set the value of navigateWindowEnabled
*
* @param navigateWindowEnabled new value of navigateWindowEnabled
*/
public void setNavigateWindowEnabled(boolean navigateWindowEnabled) {
this.navigateWindowEnabled = navigateWindowEnabled;
}

/**
* Return groups where this project belongs
*
Expand Down
2 changes: 1 addition & 1 deletion src/org/opensolaris/opengrok/web/Scripts.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public String toHtml() {
SCRIPTS.put("jquery-tablesorter", new FileScript("js/jquery-tablesorter-2.26.6.min.js", 12));
SCRIPTS.put("tablesorter-parsers", new FileScript("js/tablesorter-parsers-0.0.1.js", 13));
SCRIPTS.put("searchable-option-list", new FileScript("js/searchable-option-list-2.0.3.min.js", 14));
SCRIPTS.put("utils", new FileScript("js/utils-0.0.12.js", 15));
SCRIPTS.put("utils", new FileScript("js/utils-0.0.13.js", 15));
SCRIPTS.put("repos", new FileScript("js/repos-0.0.1.js", 20));
SCRIPTS.put("diff", new FileScript("js/diff-0.0.2.js", 20));
}
Expand Down
7 changes: 6 additions & 1 deletion web/js/utils-0.0.12.js → web/js/utils-0.0.13.js
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,7 @@
load: function ($window) {
var that = this
$window.css('top', this.getTopOffset() + 10 + 'px')

if ($.scopesWindow && $.scopesWindow.initialized) {
$.scopesWindow.on('show', function () {
setTimeout(function () {
Expand All @@ -1215,6 +1216,10 @@
}
}

if ($('[data-navigate-window-enabled="true"]').length) {
$window.show();
}

// override and show to throw an event and update position
$.each(['show'], function () {
var event = this
Expand All @@ -1241,7 +1246,7 @@
for (var j = 0; j < data[i][2].length; j ++)
$ul.append($('<li>').append(this.buildLink(data[i][2][j][1], data[i][2][j][0], data[i][1])));
}

this.updatePosition(this.$window)
}
}, options || {
}), $.extend({
Expand Down
7 changes: 5 additions & 2 deletions web/list.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ document.pageReady.push(function() { pageReadyList();});
PageConfig cfg = PageConfig.get(request);
String rev = cfg.getRequestedRevision();
String navigateWindowEnabled = cfg.getProject() != null
? Boolean.toString(cfg.getProject().isNavigateWindowEnabled())
: "false";
File resourceFile = cfg.getResourceFile();
String path = cfg.getPath();
String basename = resourceFile.getName();
Expand Down Expand Up @@ -236,7 +239,7 @@ Binary file [Click <a href="<%= rawPath %>?r=<%= Util.URIEncode(rev) %>">here</a
}
if (xrefFile != null) {
%>
<div id="src">
<div id="src" data-navigate-window-enabled="<%= navigateWindowEnabled %>">
<pre><%
Util.dump(out, xrefFile, xrefFile.getName().endsWith(".gz"));
%></pre>
Expand All @@ -262,7 +265,7 @@ Binary file [Click <a href="<%= rawPath %>?r=<%= Util.URIEncode(rev) %>">here</a
Util.dump(out, r);
} else if (g == Genre.PLAIN) {
%>
<div id="src">
<div id="src" data-navigate-window-enabled="<%= navigateWindowEnabled %>">
<pre><%
// We're generating xref for the latest revision, so we can
// find the definitions in the index.
Expand Down

0 comments on commit 3ef7a06

Please sign in to comment.