Kimchi is currently not able to configure and open help pages of any
plugin tab. This patch fixes this problem and removes the HELP button
if any Kimchi tab or plugin tab do not have a help configured properly
for the language being used.
(eg. if plugins/<tab_html>/help/<lang>/<tab_html>.html does not exist,
then the help button is disabled).
A help page for a plugin tab follow same Kimchi system:
- html help file should have the same name of plugin html tab file;
- html files should be placed in plugin's " ui/pages/help/<LANG> "
path;
- plugin should add following lines to <PLUGIN_NAME>.conf:
* [/help]
* tools.staticdir.on = True
* tools.nocache.on = True
* tools.staticdir.dir = '<HELP PAGE DIRECTORY>'
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.main.js | 55 ++++++++++++++++++++++++++++++++++++++----------
1 file changed, 44 insertions(+), 11 deletions(-)
diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js
index a3305e9..0e35218 100644
--- a/ui/js/src/kimchi.main.js
+++ b/ui/js/src/kimchi.main.js
@@ -49,9 +49,17 @@ kimchi.main = function() {
var path = tab['path'];
var mode = tab['mode'];
if (mode != 'none') {
+ var pathHelpTest = path;
+ if (/^tabs/.test(path))
+ pathHelpTest = path.split(".")[0];
+ else if (/^plugins/.test(path))
+ pathHelpTest = path.substring(0, path.lastIndexOf('.html'));
+ var disableHelp = kimchi.checkHelpFile(pathHelpTest);
+ if (disableHelp != " disableHelp")
+ disableHelp = "";
tabsHtml.push(
'<li>',
- '<a class="item" href="', path,
'">',
+ '<a class="item', disableHelp,'"
href="', path, '">',
title,
'</a>',
'</li>'
@@ -172,7 +180,15 @@ kimchi.main = function() {
$('#nav-menu a').removeClass('current');
$(tab).addClass('current');
$(tab).focus();
-
+ // Disable Help button according to selected tab
+ if ($(tab).hasClass("disableHelp")) {
+ $('#btn-help').prop('disabled', true);
+ $('#btn-help').hide();
+ }
+ else {
+ $('#btn-help').prop('disabled', false);
+ $('#btn-help').show();
+ }
// Load page content.
loadPage(url);
};
@@ -265,7 +281,7 @@ kimchi.main = function() {
event.preventDefault();
});
- $('#btn-help').on('click', kimchi.getHelp);
+ $('#btn-help').on('click', kimchi.openHelp);
};
var initUI = function() {
@@ -307,15 +323,32 @@ kimchi.main = function() {
});
};
-kimchi.getHelp = function(e) {
- var url = window.location.hash;
- var lang = kimchi.lang.get();
- url = url.replace("#tabs", "/help/" + lang);
- if (url == "/help" + lang)
- url = url + "/index.html"
- else
- url = url + ".html";
+kimchi.checkHelpFile = function(path) {
+ var lang = kimchi.lang.get();
+ var url = path.replace("tabs", "/help/" + lang);
+ if (url == "/help" + lang)
+ url = url + "/index.html"
+ else if (/^plugins/.test(url)) {
+ var tabName = url.substring(url.lastIndexOf('/'));
+ url = url.replace(tabName, "/help/" + lang + tabName +
".html");
+ $.ajax({
+ url: url,
+ async: false,
+ error: function() { url = " disableHelp"; },
+ success: function() { }
+ });
+ }
+ else
+ url = url + ".html";
+ return url;
+};
+
+
+kimchi.openHelp = function(e) {
+ var path = window.location.hash;
+ path = path.replace("#", "");
+ url = kimchi.checkHelpFile(path);
window.open(url, "Kimchi Help");
e.preventDefault();
};
--
1.9.3