Skip to content

Commit

Permalink
Disable context menu in deployment mode (override with -Ddashboard.en…
Browse files Browse the repository at this point in the history
…ableContext=true)
  • Loading branch information
papegaaij committed Nov 22, 2010
1 parent 177f867 commit cc2d992
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Expand Up @@ -136,6 +136,18 @@ public boolean isDevelopment() {
return Application.DEVELOPMENT.equals(getConfigurationType());
}

public boolean isContextMenuDisabled() {
if (isDevelopment())
return false;
try {
return !Boolean.parseBoolean(System
.getProperty("dashboard.enableContext"));
} catch (Exception e) {
// Ignore - we're not allowed to read system properties.
}
return false;
}

public DashboardRepository getRepository() {
if (getMode() == DashboardMode.RandomData)
return randomRepository;
Expand Down
Expand Up @@ -108,7 +108,10 @@ public void contribute(WiQueryResourceManager manager) {

@Override
public JsStatement statement() {
return new JsQuery(this).$().chain("dashboardClock",
"'resources/application/starttime'");
return new JsQuery(this).$().chain(
"dashboardClock",
"'resources/application/starttime'",
Boolean.toString(WicketApplication.get()
.isContextMenuDisabled()));
}
}
@@ -1,8 +1,14 @@
(function($) {
jQuery.fn.dashboardClock = function(starttimeUrl) {
jQuery.fn.dashboardClock = function(starttimeUrl, disableContext) {
var starttime = '';
var doc = $(document);

if (disableContext) {
doc.bind("contextmenu", function(e) {
e.preventDefault();
});
}

doc.data("dashboard-heartbeat-enabled", true);
doc.data("dashboard-heartbeat-count", 0);
doc.everyTime("1s", "heartbeat-bar-graph", function() {
Expand All @@ -22,8 +28,7 @@
});
doc.everyTime("200ms", "clock-update", function() {
var date = new Date();
$(".clock .time").text(date.toTimeString().substring(0,8));
// $(".clock .date").text(date.getDate()+"-"+(date.getMonth()+1)+"-"+date.getFullYear());
$(".clock .time").text(date.toTimeString().substring(0, 8));
$(".clock .date").text(date.toLocaleDateString());
});
$("#stoplink").click(function() {
Expand Down

0 comments on commit cc2d992

Please sign in to comment.