Skip to content

Commit

Permalink
Allow to set the help resources path. Fixes #457.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Mar 1, 2018
1 parent 2df9283 commit 2dbe086
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
15 changes: 15 additions & 0 deletions src/app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ dwv.App = function ()
// listeners
var listeners = {};

// help resources path
var helpResourcesPath = "./";

/**
* Get the image.
* @return {Image} The associated image.
Expand Down Expand Up @@ -165,6 +168,14 @@ dwv.App = function ()
*/
this.getStyle = function () { return style; };

/**
* Get the help resources path.
* @return {String} The path.
*/
this.getHelpResourcesPath = function () {
return helpResourcesPath;
};

/**
* Add a command to the undo stack.
* @param {Object} The command to add.
Expand Down Expand Up @@ -297,6 +308,10 @@ dwv.App = function ()
if ( config.isMobile !== "undefined" ) {
isMobile = config.isMobile;
}
// help resources path
if ( typeof config.helpResourcesPath !== "undefined" ) {
helpResourcesPath = config.helpResourcesPath;
}
dwv.gui.appendHelpHtml( toolboxController.getToolList(), isMobile, this );
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/gui/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ dwv.gui.base.appendHelpHtml = function(toolList, mobile, app)

var toolHelpDiv = document.createElement("div");

// current location
var loc = window.location.pathname;
var dir = loc.substring(0, loc.lastIndexOf('/'));

var tool = null;
var tkeys = Object.keys(toolList);
for ( var t=0; t < tkeys.length; ++t )
Expand All @@ -55,7 +51,7 @@ dwv.gui.base.appendHelpHtml = function(toolList, mobile, app)
var action = tool.getHelp()[actionType][keys[i]];

var img = document.createElement("img");
img.src = dir + "/../../resources/help/"+keys[i]+".png";
img.src = app.getHelpResourcesPath() + "/" + keys[i] + ".png";
img.style.float = "left";
img.style.margin = "0px 15px 15px 0px";

Expand Down
3 changes: 2 additions & 1 deletion viewers/mobile/applauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function startApp() {
"tools": ["Scroll", "WindowLevel", "ZoomAndPan", "Draw", "Livewire", "Filter", "Floodfill"],
"filters": ["Threshold", "Sharpen", "Sobel"],
"shapes": ["Arrow", "Ruler", "Protractor", "Rectangle", "Roi", "Ellipse", "FreeHand"],
"isMobile": true
"isMobile": true,
"helpResourcesPath": "../../resources/help"
//"defaultCharacterSet": "chinese"
};
if ( dwv.browser.hasInputDirectory() ) {
Expand Down
3 changes: 2 additions & 1 deletion viewers/static/applauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function startApp() {
"tools": ["Scroll", "WindowLevel", "ZoomAndPan", "Draw", "Livewire", "Filter", "Floodfill"],
"filters": ["Threshold", "Sharpen", "Sobel"],
"shapes": ["Arrow", "Ruler", "Protractor", "Rectangle", "Roi", "Ellipse", "FreeHand"],
"isMobile": false
"isMobile": false,
"helpResourcesPath": "../../resources/help"
};
if ( dwv.browser.hasInputDirectory() ) {
options.loaders.splice(1, 0, "Folder");
Expand Down

0 comments on commit 2dbe086

Please sign in to comment.