]> git.proxmox.com Git - proxmox-widget-toolkit.git/blame - button/HelpButton.js
use eslint and execute as check target
[proxmox-widget-toolkit.git] / button / HelpButton.js
CommitLineData
a3489b10
DM
1/* help button pointing to an online documentation
2 for components contained in a modal window
3*/
a3489b10
DM
4Ext.define('Proxmox.button.Help', {
5 extend: 'Ext.button.Button',
6 xtype: 'proxmoxHelpButton',
7
8 text: gettext('Help'),
9
10 // make help button less flashy by styling it like toolbar buttons
11 iconCls: ' x-btn-icon-el-default-toolbar-small fa fa-question-circle',
12 cls: 'x-btn-default-toolbar-small proxmox-inline-button',
13
14 hidden: true,
15
16 listenToGlobalEvent: true,
17
18 controller: {
19 xclass: 'Ext.app.ViewController',
20 listen: {
21 global: {
22 proxmoxShowHelp: 'onProxmoxShowHelp',
01031528
TL
23 proxmoxHideHelp: 'onProxmoxHideHelp',
24 },
a3489b10
DM
25 },
26 onProxmoxShowHelp: function(helpLink) {
05a977a2
TL
27 let view = this.getView();
28 if (view.listenToGlobalEvent === true) {
29 view.setOnlineHelp(helpLink);
30 view.show();
a3489b10
DM
31 }
32 },
33 onProxmoxHideHelp: function() {
05a977a2
TL
34 let view = this.getView();
35 if (view.listenToGlobalEvent === true) {
36 view.hide();
a3489b10 37 }
01031528 38 },
a3489b10
DM
39 },
40
41 // this sets the link and the tooltip text
01031528 42 setOnlineHelp: function(blockid) {
05a977a2 43 let me = this;
a3489b10 44
05a977a2 45 let info = Proxmox.Utils.get_help_info(blockid);
a3489b10
DM
46 if (info) {
47 me.onlineHelp = blockid;
05a977a2 48 let title = info.title;
a3489b10
DM
49 if (info.subtitle) {
50 title += ' - ' + info.subtitle;
51 }
52 me.setTooltip(title);
53 }
54 },
55
56 // helper to set the onlineHelp via a config object
57 setHelpConfig: function(config) {
05a977a2 58 let me = this;
a3489b10
DM
59 me.setOnlineHelp(config.onlineHelp);
60 },
61
62 handler: function() {
05a977a2
TL
63 let me = this;
64 let docsURI;
a3489b10
DM
65
66 if (me.onlineHelp) {
1098bee4 67 docsURI = Proxmox.Utils.get_help_link(me.onlineHelp);
a3489b10
DM
68 }
69
70 if (docsURI) {
71 window.open(docsURI);
72 } else {
73 Ext.Msg.alert(gettext('Help'), gettext('No Help available'));
74 }
75 },
76
77 initComponent: function() {
05a977a2 78 let me = this;
a3489b10
DM
79
80 me.callParent();
81
01031528 82 if (me.onlineHelp) {
a3489b10
DM
83 me.setOnlineHelp(me.onlineHelp); // set tooltip
84 }
01031528 85 },
a3489b10 86});