pardus-options-library 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +323 -0
- package/eslint.config.js +38 -0
- package/package.json +32 -0
- package/src/classes/abstract/abstract-button.js +116 -0
- package/src/classes/abstract/abstract-toggle-button.js +145 -0
- package/src/classes/contents-area.js +22 -0
- package/src/classes/description-element.js +80 -0
- package/src/classes/disableable-html-element.js +48 -0
- package/src/classes/html-element.js +189 -0
- package/src/classes/info-element.js +56 -0
- package/src/classes/options/abstract-array-option.js +38 -0
- package/src/classes/options/abstract-option.js +189 -0
- package/src/classes/options/boolean-option.js +24 -0
- package/src/classes/options/grouped-options.js +61 -0
- package/src/classes/options/key-down-disable-button.js +20 -0
- package/src/classes/options/key-down-option.js +178 -0
- package/src/classes/options/key-down-set-key-button.js +18 -0
- package/src/classes/options/numeric-option.js +40 -0
- package/src/classes/options/select-option.js +74 -0
- package/src/classes/options/text-area-option.js +39 -0
- package/src/classes/options-box.js +200 -0
- package/src/classes/options-content.js +178 -0
- package/src/classes/options-group.js +114 -0
- package/src/classes/pardus-options-utility.js +139 -0
- package/src/classes/pardus-options.js +144 -0
- package/src/classes/save-button-row/load-button.js +21 -0
- package/src/classes/save-button-row/preset-label.js +95 -0
- package/src/classes/save-button-row/preset-row.js +106 -0
- package/src/classes/save-button-row/presets.js +57 -0
- package/src/classes/save-button-row/reset-button.js +21 -0
- package/src/classes/save-button-row/save-button-row.js +69 -0
- package/src/classes/save-button-row/save-button.js +21 -0
- package/src/classes/tabs/sub-tab.js +66 -0
- package/src/classes/tabs/tab-content.js +149 -0
- package/src/classes/tabs/tab-label.js +45 -0
- package/src/classes/tabs/tab.js +66 -0
- package/src/classes/tabs/tabs-element.js +25 -0
- package/src/classes/tabs/tabs-row.js +44 -0
- package/src/classes/tip-box.js +69 -0
- package/src/classes/version-row.js +14 -0
- package/src/index.js +13 -0
- package/webpack.config.cjs +16 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import DisableableHtmlElement from '../disableable-html-element.js';
|
|
2
|
+
import SaveButton from './save-button.js';
|
|
3
|
+
import LoadButton from './load-button.js';
|
|
4
|
+
import PresetLabel from './preset-label.js';
|
|
5
|
+
|
|
6
|
+
export default class PresetRow extends DisableableHtmlElement {
|
|
7
|
+
constructor({
|
|
8
|
+
id,
|
|
9
|
+
premium = false,
|
|
10
|
+
disabled = false,
|
|
11
|
+
presetNumber,
|
|
12
|
+
}) {
|
|
13
|
+
super({
|
|
14
|
+
id,
|
|
15
|
+
disabled,
|
|
16
|
+
});
|
|
17
|
+
this.premium = premium;
|
|
18
|
+
this.saveButton = new SaveButton({
|
|
19
|
+
id: `${this.id}-save-button`,
|
|
20
|
+
premium,
|
|
21
|
+
disabled,
|
|
22
|
+
});
|
|
23
|
+
this.loadButton = new LoadButton({
|
|
24
|
+
id: `${this.id}-load-button`,
|
|
25
|
+
premium,
|
|
26
|
+
disabled,
|
|
27
|
+
});
|
|
28
|
+
this.presetNumber = presetNumber;
|
|
29
|
+
this.label = new PresetLabel({
|
|
30
|
+
id: `${this.id}-label`,
|
|
31
|
+
defaultValue: `Preset ${this.presetNumber}`,
|
|
32
|
+
disabled,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (!this.hasValue()) {
|
|
36
|
+
this.loadButton.disable();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
toString() {
|
|
41
|
+
return `<tr id="${this.id}"><td align="left">${this.label}</input></td><td align="right">${this.loadButton} ${this.saveButton}</td></tr>`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Allows disabling or enabling this element and all nested elements without refreshing
|
|
46
|
+
* @function PresetRow#setDisabled
|
|
47
|
+
*/
|
|
48
|
+
setDisabled(disabled = false) {
|
|
49
|
+
this.disabled = disabled;
|
|
50
|
+
this.saveButton.setDisabled(disabled);
|
|
51
|
+
this.loadButton.setDisabled(disabled);
|
|
52
|
+
this.label.setDisabled(disabled);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
displaySaved() {
|
|
56
|
+
this.saveButton.displaySaved();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
displayLoaded() {
|
|
60
|
+
if (this.loadButton) {
|
|
61
|
+
this.loadButton.displayLoaded();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
hasValue() {
|
|
66
|
+
return this.label.hasValue();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setFunctions(options) {
|
|
70
|
+
if (options.length !== 0) {
|
|
71
|
+
this.addSaveEventListener(() => {
|
|
72
|
+
for (const option of options) {
|
|
73
|
+
option.saveValue((name, value) => {
|
|
74
|
+
option.saveFunction(`preset-${this.presetNumber}-${name}`, value);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
this.displaySaved();
|
|
78
|
+
this.loadButton.enable();
|
|
79
|
+
|
|
80
|
+
this.label.save();
|
|
81
|
+
|
|
82
|
+
const event = new Event('preset-save', { bubbles: true });
|
|
83
|
+
this.getElement().dispatchEvent(event);
|
|
84
|
+
});
|
|
85
|
+
this.addLoadEventListener(() => {
|
|
86
|
+
for (const option of options) {
|
|
87
|
+
option.loadValue(option.getValue((name, value) => option.getFunction(`preset-${this.presetNumber}-${name}`, value)));
|
|
88
|
+
}
|
|
89
|
+
this.displayLoaded();
|
|
90
|
+
|
|
91
|
+
const event = new Event('preset-load', { bubbles: true });
|
|
92
|
+
this.getElement().dispatchEvent(event);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
addSaveEventListener(func) {
|
|
98
|
+
this.saveButton.addEventListener('click', func);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
addLoadEventListener(func) {
|
|
102
|
+
if (this.loadButton) {
|
|
103
|
+
this.loadButton.addEventListener('click', func);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import DisableableHtmlElement from '../disableable-html-element.js';
|
|
2
|
+
import PresetRow from './preset-row.js';
|
|
3
|
+
|
|
4
|
+
export default class Presets extends DisableableHtmlElement {
|
|
5
|
+
constructor({
|
|
6
|
+
id,
|
|
7
|
+
premium = false,
|
|
8
|
+
disabled = false,
|
|
9
|
+
presets = 0,
|
|
10
|
+
}) {
|
|
11
|
+
super({
|
|
12
|
+
id,
|
|
13
|
+
disabled,
|
|
14
|
+
});
|
|
15
|
+
this.premium = premium;
|
|
16
|
+
this.presets = [];
|
|
17
|
+
for (let i = 0; i < presets; i += 1) {
|
|
18
|
+
this.presets.push(new PresetRow({
|
|
19
|
+
id: `${this.id}-preset-row-${i}`,
|
|
20
|
+
premium,
|
|
21
|
+
disabled,
|
|
22
|
+
presetNumber: i + 1,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Allows disabling or enabling this element and all nested elements without refreshing
|
|
29
|
+
* @function Presets#setDisabled
|
|
30
|
+
*/
|
|
31
|
+
setDisabled(disabled = false) {
|
|
32
|
+
this.disabled = disabled;
|
|
33
|
+
for (const preset of this.presets) {
|
|
34
|
+
preset.setDisabled(disabled);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toString() {
|
|
39
|
+
if (this.presets.length === 0) {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let html = `<tr id="${this.id}"><td><table width="100%">`;
|
|
44
|
+
|
|
45
|
+
for (const presetRow of this.presets) {
|
|
46
|
+
html += presetRow;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return `${html}</table></td></tr>`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setFunctions(options) {
|
|
53
|
+
for (const presetRow of this.presets) {
|
|
54
|
+
presetRow.setFunctions(options);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import AbstractButton from '../abstract/abstract-button.js';
|
|
2
|
+
|
|
3
|
+
export default class ResetButton extends AbstractButton {
|
|
4
|
+
constructor({
|
|
5
|
+
id,
|
|
6
|
+
premium = false,
|
|
7
|
+
disabled = false,
|
|
8
|
+
}) {
|
|
9
|
+
super({
|
|
10
|
+
id,
|
|
11
|
+
premium,
|
|
12
|
+
disabled,
|
|
13
|
+
actionText: 'Reset',
|
|
14
|
+
actionPerformedText: 'Reset',
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
displayReset() {
|
|
19
|
+
this.displayClicked();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import DisableableHtmlElement from '../disableable-html-element.js';
|
|
2
|
+
import SaveButton from './save-button.js';
|
|
3
|
+
import ResetButton from './reset-button.js';
|
|
4
|
+
|
|
5
|
+
export default class SaveButtonRow extends DisableableHtmlElement {
|
|
6
|
+
constructor({
|
|
7
|
+
id,
|
|
8
|
+
premium = false,
|
|
9
|
+
resetButton = false,
|
|
10
|
+
disabled = false,
|
|
11
|
+
}) {
|
|
12
|
+
super({
|
|
13
|
+
id,
|
|
14
|
+
disabled,
|
|
15
|
+
});
|
|
16
|
+
this.premium = premium;
|
|
17
|
+
this.saveButton = new SaveButton({
|
|
18
|
+
id: `${this.id}-button`,
|
|
19
|
+
premium,
|
|
20
|
+
disabled,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (resetButton) {
|
|
24
|
+
this.resetButton = new ResetButton({
|
|
25
|
+
id: `${this.id}-reset-button`,
|
|
26
|
+
premium,
|
|
27
|
+
disabled,
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
this.resetButton = null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
toString() {
|
|
35
|
+
return `<tr id="${this.id}"><td align="right" style="padding-right: 6px;">${(this.resetButton) ? `${this.resetButton} ` : ''}${this.saveButton}</td></tr>`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Allows disabling or enabling this element and all nested elements without refreshing
|
|
40
|
+
* @function SaveButtonRow#setDisabled
|
|
41
|
+
*/
|
|
42
|
+
setDisabled(disabled = false) {
|
|
43
|
+
this.disabled = disabled;
|
|
44
|
+
this.saveButton.setDisabled(disabled);
|
|
45
|
+
if (this.resetButton) {
|
|
46
|
+
this.resetButton.setDisabled(disabled);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
displaySaved() {
|
|
51
|
+
this.saveButton.displaySaved();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
displayReset() {
|
|
55
|
+
if (this.resetButton) {
|
|
56
|
+
this.resetButton.displayReset();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
addSaveEventListener(func) {
|
|
61
|
+
this.saveButton.addEventListener('click', func);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
addResetEventListener(func) {
|
|
65
|
+
if (this.resetButton) {
|
|
66
|
+
this.resetButton.addEventListener('click', func);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import AbstractButton from '../abstract/abstract-button.js';
|
|
2
|
+
|
|
3
|
+
export default class SaveButton extends AbstractButton {
|
|
4
|
+
constructor({
|
|
5
|
+
id,
|
|
6
|
+
premium = false,
|
|
7
|
+
disabled = false,
|
|
8
|
+
}) {
|
|
9
|
+
super({
|
|
10
|
+
id,
|
|
11
|
+
premium,
|
|
12
|
+
disabled,
|
|
13
|
+
actionText: 'Save',
|
|
14
|
+
actionPerformedText: 'Saved',
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
displaySaved() {
|
|
19
|
+
this.displayClicked();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import PardusOptionsUtility from '../pardus-options-utility.js';
|
|
2
|
+
import OptionsContent from '../options-content.js';
|
|
3
|
+
import TabLabel from './tab-label.js';
|
|
4
|
+
|
|
5
|
+
export default class SubTab {
|
|
6
|
+
constructor({
|
|
7
|
+
id,
|
|
8
|
+
label,
|
|
9
|
+
saveFunction = PardusOptionsUtility.defaultSaveFunction,
|
|
10
|
+
getFunction = PardusOptionsUtility.defaultGetFunction,
|
|
11
|
+
refresh = true,
|
|
12
|
+
active = false,
|
|
13
|
+
padding,
|
|
14
|
+
}) {
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.active = active;
|
|
17
|
+
this.label = new TabLabel({
|
|
18
|
+
id: `${this.id}-label`,
|
|
19
|
+
heading: label,
|
|
20
|
+
active: this.active,
|
|
21
|
+
padding,
|
|
22
|
+
});
|
|
23
|
+
this.content = new OptionsContent({
|
|
24
|
+
id: `${this.id}-content`,
|
|
25
|
+
saveFunction,
|
|
26
|
+
getFunction,
|
|
27
|
+
refresh,
|
|
28
|
+
active: this.active,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setActive() {
|
|
33
|
+
if (this.active === true) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.active = true;
|
|
37
|
+
this.label.setActive();
|
|
38
|
+
this.content.setActive();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setInactive() {
|
|
42
|
+
if (this.active === false) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.active = false;
|
|
46
|
+
this.label.setInactive();
|
|
47
|
+
this.content.setInactive();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
afterRefreshElement(opts) {
|
|
51
|
+
this.label.afterRefreshElement(opts);
|
|
52
|
+
this.content.afterRefreshElement(opts);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getLabel() {
|
|
56
|
+
return this.label;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getContent() {
|
|
60
|
+
return this.content;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
toString() {
|
|
64
|
+
return this.content.toString();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import HtmlElement from '../html-element.js';
|
|
2
|
+
import PardusOptionsUtility from '../pardus-options-utility.js';
|
|
3
|
+
import TabsRow from './tabs-row.js';
|
|
4
|
+
import SubTab from './sub-tab.js';
|
|
5
|
+
import VersionRow from '../version-row.js';
|
|
6
|
+
|
|
7
|
+
export default class TabContent extends HtmlElement {
|
|
8
|
+
constructor({
|
|
9
|
+
id,
|
|
10
|
+
heading,
|
|
11
|
+
defaultLabel = 'Default tab',
|
|
12
|
+
content = null,
|
|
13
|
+
saveFunction = PardusOptionsUtility.defaultSaveFunction,
|
|
14
|
+
getFunction = PardusOptionsUtility.defaultGetFunction,
|
|
15
|
+
refresh = true,
|
|
16
|
+
}) {
|
|
17
|
+
super(id);
|
|
18
|
+
this.heading = heading;
|
|
19
|
+
this.content = content;
|
|
20
|
+
this.saveFunction = saveFunction;
|
|
21
|
+
this.getFunction = getFunction;
|
|
22
|
+
this.subTabsRow = new TabsRow({
|
|
23
|
+
id: `${this.id}-tabsrow`,
|
|
24
|
+
});
|
|
25
|
+
this.refresh = refresh;
|
|
26
|
+
this.subTabs = [];
|
|
27
|
+
this.defaultTab = this.addSubTab({
|
|
28
|
+
label: defaultLabel,
|
|
29
|
+
saveFunction: this.saveFunction,
|
|
30
|
+
getFunction: this.getFunction,
|
|
31
|
+
refresh: false,
|
|
32
|
+
active: true,
|
|
33
|
+
});
|
|
34
|
+
this.versionRow = new VersionRow({
|
|
35
|
+
id: `${this.id}-versionrow`,
|
|
36
|
+
});
|
|
37
|
+
this.addAfterRefreshHook((opts) => {
|
|
38
|
+
if (opts.maintainRefreshStatus) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.refresh = true;
|
|
42
|
+
});
|
|
43
|
+
this.addAfterRefreshHook((opts) => {
|
|
44
|
+
if (!this.refresh && opts.maintainRefreshStatus) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
for (const subTab of this.subTabs) {
|
|
48
|
+
subTab.afterRefreshElement(opts);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
addSubTab({
|
|
54
|
+
label,
|
|
55
|
+
saveFunction = this.saveFunction,
|
|
56
|
+
getFunction = this.getFunction,
|
|
57
|
+
refresh = this.refresh,
|
|
58
|
+
active = false,
|
|
59
|
+
padding,
|
|
60
|
+
}) {
|
|
61
|
+
const newSubTab = new SubTab({
|
|
62
|
+
id: `${this.id}-subtab-${this.subTabs.length}`,
|
|
63
|
+
label,
|
|
64
|
+
saveFunction,
|
|
65
|
+
getFunction,
|
|
66
|
+
refresh,
|
|
67
|
+
active,
|
|
68
|
+
padding,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const newSubTabContent = newSubTab.getContent();
|
|
72
|
+
const newSubTabLabel = newSubTab.getLabel();
|
|
73
|
+
|
|
74
|
+
this.subTabsRow.addLabel({
|
|
75
|
+
label: newSubTabLabel,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
this.subTabs.push(newSubTab);
|
|
79
|
+
|
|
80
|
+
newSubTabLabel.addEventListener('click', () => {
|
|
81
|
+
this.setActiveSubTab(newSubTab.id);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (refresh) {
|
|
85
|
+
this.refreshElement();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return newSubTabContent;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setActiveSubTab(subTabId) {
|
|
92
|
+
for (const subTab of this.subTabs) {
|
|
93
|
+
if (subTab.id === subTabId) {
|
|
94
|
+
subTab.setActive();
|
|
95
|
+
} else {
|
|
96
|
+
subTab.setInactive();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
addBox(args) {
|
|
102
|
+
return this.defaultTab.addBox(args);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
addBoxBottom(args) {
|
|
106
|
+
return this.defaultTab.addBoxBottom(args);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
addBoxTop(args) {
|
|
110
|
+
return this.defaultTab.addBoxTop(args);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
addBoxLeft(args) {
|
|
114
|
+
return this.defaultTab.addBoxLeft(args);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
addBoxRight(args) {
|
|
118
|
+
return this.defaultTab.addBoxRight(args);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
addPremiumBox(args) {
|
|
122
|
+
return this.defaultTab.addPremiumBox(args);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
addPremiumBoxLeft(args) {
|
|
126
|
+
return this.defaultTab.addPremiumBoxLeft(args);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
addPremiumBoxRight(args) {
|
|
130
|
+
return this.defaultTab.addPremiumBoxRight(args);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
setActive() {
|
|
134
|
+
this.getElement().removeAttribute('hidden');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
setInactive() {
|
|
138
|
+
this.getElement().setAttribute('hidden', '');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
toString() {
|
|
142
|
+
if (this.content !== null) {
|
|
143
|
+
return this.content;
|
|
144
|
+
}
|
|
145
|
+
const hidden = (this.subTabs.length > 1) ? '' : 'hidden';
|
|
146
|
+
const innerStyle = (this.subTabs.length > 1) ? 'class="tabstyle"' : '';
|
|
147
|
+
return `<table id="${this.id}" hidden class="tabstyle" style="background:url(${PardusOptionsUtility.getImagePackUrl()}bgdark.gif)" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td><div align="center"><h1>${this.heading}</h1></div></td></tr><tr><td><table width="100%" align="center" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td><table cellspacing="0" cellpadding="0" border="0" ${hidden}><tbody>${this.subTabsRow}</tbody></table></td></tr><tr><td><table ${innerStyle} cellspacing="0" cellpadding="0" border="0"><tbody>${this.subTabs.join('')}</tbody></table></td></tr></tbody></table></td></tr>${this.versionRow}</tbody></table>`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import HtmlElement from '../html-element.js';
|
|
2
|
+
import PardusOptionsUtility from '../pardus-options-utility.js';
|
|
3
|
+
|
|
4
|
+
export default class TabLabel extends HtmlElement {
|
|
5
|
+
constructor({
|
|
6
|
+
id,
|
|
7
|
+
heading,
|
|
8
|
+
active = false,
|
|
9
|
+
padding = '10px',
|
|
10
|
+
}) {
|
|
11
|
+
super(id);
|
|
12
|
+
this.padding = padding;
|
|
13
|
+
this.heading = heading;
|
|
14
|
+
this.active = active;
|
|
15
|
+
this.addEventListener('mouseover', () => {
|
|
16
|
+
if (this.active) {
|
|
17
|
+
this.getElement().style.cursor = 'default';
|
|
18
|
+
} else {
|
|
19
|
+
this.getElement().style.backgroundImage = `url(${PardusOptionsUtility.getImagePackUrl()}tabactive.png)`;
|
|
20
|
+
this.getElement().style.cursor = 'default';
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
this.addEventListener('mouseout', () => {
|
|
24
|
+
if (!this.active) {
|
|
25
|
+
this.getElement().style.backgroundImage = `url(${PardusOptionsUtility.getImagePackUrl()}tab.png)`;
|
|
26
|
+
this.getElement().style.cursor = 'default';
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
toString() {
|
|
32
|
+
const imageUrl = (this.active) ? 'tabactive' : 'tab';
|
|
33
|
+
return `<td id="${this.id}" style="background: transparent url("${PardusOptionsUtility.getImagePackUrl()}${imageUrl}.png") no-repeat scroll 0% 0%; background-size: cover; cursor: default; padding-left: ${this.padding}; padding-right: ${this.padding}; box-sizing: border-box" class="tabcontent">${this.heading}</td>`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setActive() {
|
|
37
|
+
this.getElement().style.backgroundImage = `url('${PardusOptionsUtility.getImagePackUrl()}tabactive.png')`;
|
|
38
|
+
this.active = true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setInactive() {
|
|
42
|
+
this.getElement().style.backgroundImage = `url('${PardusOptionsUtility.getImagePackUrl()}tab.png')`;
|
|
43
|
+
this.active = false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import PardusOptionsUtility from '../pardus-options-utility.js';
|
|
2
|
+
import TabLabel from './tab-label.js';
|
|
3
|
+
import TabContent from './tab-content.js';
|
|
4
|
+
|
|
5
|
+
export default class Tab {
|
|
6
|
+
constructor({
|
|
7
|
+
id,
|
|
8
|
+
heading,
|
|
9
|
+
content = null,
|
|
10
|
+
saveFunction = PardusOptionsUtility.defaultSaveFunction,
|
|
11
|
+
getFunction = PardusOptionsUtility.defaultGetFunction,
|
|
12
|
+
refresh = true,
|
|
13
|
+
defaultLabel,
|
|
14
|
+
}) {
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.heading = heading;
|
|
17
|
+
this.content = new TabContent({
|
|
18
|
+
id: `options-content-${this.id}`,
|
|
19
|
+
heading,
|
|
20
|
+
content,
|
|
21
|
+
saveFunction,
|
|
22
|
+
getFunction,
|
|
23
|
+
refresh,
|
|
24
|
+
defaultLabel,
|
|
25
|
+
});
|
|
26
|
+
this.label = new TabLabel({
|
|
27
|
+
id: `${this.id}-label`,
|
|
28
|
+
heading,
|
|
29
|
+
});
|
|
30
|
+
this.active = false;
|
|
31
|
+
this.saveFunction = saveFunction;
|
|
32
|
+
this.getFunction = getFunction;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
addListeners() {
|
|
36
|
+
this.getLabel().addEventListener('click', () => PardusOptionsUtility.setActiveTab(this.id), true);
|
|
37
|
+
window.addEventListener('storage', () => {
|
|
38
|
+
if (window.localStorage.getItem('pardusOptionsOpenTab') === this.id && !this.active) {
|
|
39
|
+
this.setActive();
|
|
40
|
+
}
|
|
41
|
+
if (window.localStorage.getItem('pardusOptionsOpenTab') !== this.id && this.active) {
|
|
42
|
+
this.setInactive();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setActive() {
|
|
48
|
+
this.label.setActive();
|
|
49
|
+
this.content.setActive();
|
|
50
|
+
this.active = true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
setInactive() {
|
|
54
|
+
this.label.setInactive();
|
|
55
|
+
this.content.setInactive();
|
|
56
|
+
this.active = false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getContent() {
|
|
60
|
+
return this.content;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getLabel() {
|
|
64
|
+
return this.label;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import HtmlElement from '../html-element.js';
|
|
2
|
+
import TabsRow from './tabs-row.js';
|
|
3
|
+
|
|
4
|
+
export default class TabsElement extends HtmlElement {
|
|
5
|
+
constructor({
|
|
6
|
+
id,
|
|
7
|
+
}) {
|
|
8
|
+
super(id);
|
|
9
|
+
this.tabsRow = new TabsRow({
|
|
10
|
+
id: `${this.id}-row`,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
addLabel({
|
|
15
|
+
label,
|
|
16
|
+
}) {
|
|
17
|
+
this.tabsRow.addLabel({
|
|
18
|
+
label,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
toString() {
|
|
23
|
+
return `<table id="${this.id}" cellspacing="0" cellpadding="0" border="0" align="left"><tbody>${this.tabsRow}</tbody></table>`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import HtmlElement from '../html-element.js';
|
|
2
|
+
|
|
3
|
+
export default class TabsRow extends HtmlElement {
|
|
4
|
+
constructor({
|
|
5
|
+
id,
|
|
6
|
+
hidden = false,
|
|
7
|
+
}) {
|
|
8
|
+
super(id);
|
|
9
|
+
this.hidden = hidden;
|
|
10
|
+
this.labels = [];
|
|
11
|
+
this.addAfterRefreshHook(() => {
|
|
12
|
+
for (const label of this.labels) {
|
|
13
|
+
label.afterRefreshElement();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
addLabel({
|
|
19
|
+
label,
|
|
20
|
+
}) {
|
|
21
|
+
this.labels.push(label);
|
|
22
|
+
if (this.getElement()) {
|
|
23
|
+
this.appendChild(label.toElement());
|
|
24
|
+
label.afterRefreshElement();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
show() {
|
|
29
|
+
this.hidden = false;
|
|
30
|
+
this.refreshElement();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
hide() {
|
|
34
|
+
this.hidden = true;
|
|
35
|
+
this.refreshElement();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toString() {
|
|
39
|
+
if (this.hidden) {
|
|
40
|
+
return `<tr id="${this.id}" cellspacing="0" cellpadding="0" border="0" hidden="">${this.labels.join('')}</tr>`;
|
|
41
|
+
}
|
|
42
|
+
return `<tr id="${this.id}" cellspacing="0" cellpadding="0" border="0">${this.labels.join('')}</tr>`;
|
|
43
|
+
}
|
|
44
|
+
}
|