0e029e08ef
pve-doc-generator used pveOnlineHelp as variable name while the widget toolkit expects proxmoxOnlineHelp, allow both for now. As its not quite clear when the switch to the widget toolkit happens this is more flexible than changing the generator and adding a versioned build dependency in pve-manager for it. We normally do not bump pve-docs during releases either. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> CC: Dominik Csapak <d.csapak@proxmox.com>
108 lines
2.3 KiB
JavaScript
108 lines
2.3 KiB
JavaScript
/* help button pointing to an online documentation
|
|
for components contained in a modal window
|
|
*/
|
|
/*global
|
|
proxmoxOnlineHelpInfo
|
|
*/
|
|
Ext.define('Proxmox.button.Help', {
|
|
extend: 'Ext.button.Button',
|
|
xtype: 'proxmoxHelpButton',
|
|
|
|
text: gettext('Help'),
|
|
|
|
// make help button less flashy by styling it like toolbar buttons
|
|
iconCls: ' x-btn-icon-el-default-toolbar-small fa fa-question-circle',
|
|
cls: 'x-btn-default-toolbar-small proxmox-inline-button',
|
|
|
|
hidden: true,
|
|
|
|
listenToGlobalEvent: true,
|
|
|
|
controller: {
|
|
xclass: 'Ext.app.ViewController',
|
|
listen: {
|
|
global: {
|
|
proxmoxShowHelp: 'onProxmoxShowHelp',
|
|
proxmoxHideHelp: 'onProxmoxHideHelp'
|
|
}
|
|
},
|
|
onProxmoxShowHelp: function(helpLink) {
|
|
var me = this.getView();
|
|
if (me.listenToGlobalEvent === true) {
|
|
me.setOnlineHelp(helpLink);
|
|
me.show();
|
|
}
|
|
},
|
|
onProxmoxHideHelp: function() {
|
|
var me = this.getView();
|
|
if (me.listenToGlobalEvent === true) {
|
|
me.hide();
|
|
}
|
|
}
|
|
},
|
|
|
|
getOnlineHelpInfo: function (ref) {
|
|
var helpMap;
|
|
if (typeof proxmoxOnlineHelpInfo !== 'undefined') {
|
|
helpMap = proxmoxOnlineHelpInfo;
|
|
} else if (typeof pveOnlineHelpInfo !== 'undefined') {
|
|
// be backward compatible with older pve-doc-generators
|
|
helpMap = pveOnlineHelpInfo;
|
|
} else {
|
|
throw "no global OnlineHelpInfo map declared";
|
|
}
|
|
|
|
return helpMap[ref];
|
|
},
|
|
|
|
// this sets the link and the tooltip text
|
|
setOnlineHelp:function(blockid) {
|
|
var me = this;
|
|
|
|
var info = me.getOnlineHelpInfo(blockid);
|
|
if (info) {
|
|
me.onlineHelp = blockid;
|
|
var title = info.title;
|
|
if (info.subtitle) {
|
|
title += ' - ' + info.subtitle;
|
|
}
|
|
me.setTooltip(title);
|
|
}
|
|
},
|
|
|
|
// helper to set the onlineHelp via a config object
|
|
setHelpConfig: function(config) {
|
|
var me = this;
|
|
me.setOnlineHelp(config.onlineHelp);
|
|
},
|
|
|
|
handler: function() {
|
|
var me = this;
|
|
var docsURI;
|
|
|
|
if (me.onlineHelp) {
|
|
var info = me.getOnlineHelpInfo(me.onlineHelp);
|
|
if (info) {
|
|
docsURI = window.location.origin + info.link;
|
|
}
|
|
}
|
|
|
|
if (docsURI) {
|
|
window.open(docsURI);
|
|
} else {
|
|
Ext.Msg.alert(gettext('Help'), gettext('No Help available'));
|
|
}
|
|
},
|
|
|
|
initComponent: function() {
|
|
/*jslint confusion: true */
|
|
var me = this;
|
|
|
|
me.callParent();
|
|
|
|
if (me.onlineHelp) {
|
|
me.setOnlineHelp(me.onlineHelp); // set tooltip
|
|
}
|
|
}
|
|
});
|