diff --git a/src/com.elgato.template.sdPlugin/actions/template/property-inspector/inspector.html b/src/com.elgato.template.sdPlugin/actions/template/property-inspector/inspector.html index db480b4..13d5a46 100644 --- a/src/com.elgato.template.sdPlugin/actions/template/property-inspector/inspector.html +++ b/src/com.elgato.template.sdPlugin/actions/template/property-inspector/inspector.html @@ -1,62 +1,78 @@ - - - - - - com.elgato.template Property Inspector - - - -
-
-
-
Name
- -
-
-
Message
-
- -
-
-
-
-
Button
- -
-
+ id="open-external"> + Click Me + + + - - - - - - - - - - - + + + + + + + + + + + + + + + - - - diff --git a/src/com.elgato.template.sdPlugin/actions/template/property-inspector/inspector.js b/src/com.elgato.template.sdPlugin/actions/template/property-inspector/inspector.js index c58df82..e8a79b9 100644 --- a/src/com.elgato.template.sdPlugin/actions/template/property-inspector/inspector.js +++ b/src/com.elgato.template.sdPlugin/actions/template/property-inspector/inspector.js @@ -18,6 +18,10 @@ $PI.onConnected((jsn) => { ); }); +$PI.onDidReceiveGlobalSettings(({payload}) => { + console.log('onDidReceiveGlobalSettings', payload); +}) + /** * Provide window level functions to use in the external window * (this can be removed if the external window is not used) @@ -29,3 +33,64 @@ window.sendToInspector = (data) => { document.querySelector('#open-external').addEventListener('click', () => { window.open('../../../external.html'); }); + + +/** + * TABS + * ---- + * + * This will make the tabs interactive: + * - clicking on a tab will make it active + * - clicking on a tab will show the corresponding content + * - clicking on a tab will hide the content of all other tabs + * - a tab must have the class "tab" + * - a tab must have a data-target attribute that points to the id of the content + * - the content must have the class "tab-content" + * - the content must have an id that matches the data-target attribute of the tab + * - the content must have a data-tab attribute that matches the data-target attribute of the tab + *
Inputs
+ *
Text
+ * a complete tab-example can be found in the index.html +
+
+
+
Inputs
+
Text
+
+
+
+ * You can use the code below to activate the tabs (`activateTabs` and `clickTab` are required) + */ + +function activateTabs(activeTab) { + const allTabs = Array.from(document.querySelectorAll('.tab')); + let activeTabEl = null; + allTabs.forEach((el, i) => { + el.onclick = () => clickTab(el); + if(el.dataset?.target === activeTab) { + activeTabEl = el; + } + }); + if(activeTabEl) { + clickTab(activeTabEl); + } else if(allTabs.length) { + clickTab(allTabs[0]); + } +} + +function clickTab(clickedTab) { + const allTabs = Array.from(document.querySelectorAll('.tab')); + allTabs.forEach((el, i) => el.classList.remove('selected')); + clickedTab.classList.add('selected'); + activeTab = clickedTab.dataset?.target; + allTabs.forEach((el, i) => { + if(el.dataset.target) { + const t = document.querySelector(el.dataset.target); + if(t) { + t.style.display = el == clickedTab ? 'block' : 'none'; + } + } + }); +} + +activateTabs(); diff --git a/src/com.elgato.template.sdPlugin/de.json b/src/com.elgato.template.sdPlugin/de.json index 815c73d..67059df 100644 --- a/src/com.elgato.template.sdPlugin/de.json +++ b/src/com.elgato.template.sdPlugin/de.json @@ -11,6 +11,7 @@ "Message": "Nachricht", "Click Me": "Klicke mich", "Button": "Taste", + "More": "Mehr", "My name": "Mein Name", "My title": "Mein Titel", "My message": "Meine Nachricht", diff --git a/src/com.elgato.template.sdPlugin/en.json b/src/com.elgato.template.sdPlugin/en.json index 6bae2b5..7b43e58 100644 --- a/src/com.elgato.template.sdPlugin/en.json +++ b/src/com.elgato.template.sdPlugin/en.json @@ -11,6 +11,7 @@ "Message": "Message", "Click Me": "Click Me", "Button": "Button", + "More": "More", "My name": "My name", "My title": "My title", "My message": "My message",