From 2dbe0866a2244c1e10578dcd71353ee7b2ab9faa Mon Sep 17 00:00:00 2001 From: ivmartel Date: Fri, 2 Mar 2018 00:11:34 +0100 Subject: [PATCH] Allow to set the help resources path. Fixes #457. --- src/app/application.js | 15 +++++++++++++++ src/gui/help.js | 6 +----- viewers/mobile/applauncher.js | 3 ++- viewers/static/applauncher.js | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/app/application.js b/src/app/application.js index 11dcf22fc4..ac44a37a2e 100644 --- a/src/app/application.js +++ b/src/app/application.js @@ -76,6 +76,9 @@ dwv.App = function () // listeners var listeners = {}; + // help resources path + var helpResourcesPath = "./"; + /** * Get the image. * @return {Image} The associated image. @@ -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. @@ -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 ); } } diff --git a/src/gui/help.js b/src/gui/help.js index 7cf36f5c7c..3be2ba1dd4 100644 --- a/src/gui/help.js +++ b/src/gui/help.js @@ -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 ) @@ -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"; diff --git a/viewers/mobile/applauncher.js b/viewers/mobile/applauncher.js index a2d4eec8c5..c90b444a9a 100644 --- a/viewers/mobile/applauncher.js +++ b/viewers/mobile/applauncher.js @@ -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() ) { diff --git a/viewers/static/applauncher.js b/viewers/static/applauncher.js index 981e57d8bb..f016207f67 100644 --- a/viewers/static/applauncher.js +++ b/viewers/static/applauncher.js @@ -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");