[MediaWiki-commits] [Gerrit] Add nested= attribute to tab tag - change (mediawiki...Tabs)
Joeytje50 has uploaded a new change for review. https://gerrit.wikimedia.org/r/184188 Change subject: Add nested= attribute to tab tag .. Add nested= attribute to tab tag now it is possible to make nested toggle boxes or dropdowns have content that depends on the selected tab; simply put a {{#tab:}} or {{#tag:tab}} with |nested=true as last argument inside the toggle/dropdown box. Change-Id: I413ebfc42213ae6e88cd87343cc620fc62016571 --- M README.md M Tabs.body.php M Tabs.php 3 files changed, 33 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Tabs refs/changes/88/184188/1 diff --git a/README.md b/README.md index aedad16..d895546 100644 --- a/README.md +++ b/README.md @@ -360,6 +360,17 @@ |dropdown=true}} = Toggle boxes and dropdowns in tab boxes = + +If you want to place a toggle box or a dropdown inside a tab navigation, and want the toggle box to show up for every tab as opposed to just the tab it's nested in, first a parent codelt;tabgt;/code tab must be made, with codeindex=*/code, so that the toggle box won't be recognised as a seperate tab content. + +If you want to place a toggle box or dropdown menu inside a tab menu, you can simply place a codelt;tabgt;/code tag inside the codelt;tabgt;/code tag that functions as a tab. This will restrict toggle boxes and dropdowns to visibility in just one tab though. So, if you want to have a toggle box or dropdown that's visible in every tab, encase it in a codelt;tabgt;/code tag with an codeindex=*/code set to it. + +That way, the outer codelt;tabgt;/code tag will be recognised as a tab container, and the inner one will be recognised as a toggle box or dropdown menu, as desired. The toggle box or dropdown must then also use the [[#General usage information|parser function syntax]]. + +If you want the contents of the toggle box inside the tab menu to be able to change depending on the selected tab, you should use the codenested=true/code attribute on the tag. This can be done by setting the very last argument of the code#tab:/code parser function or the code#tag:tab/code parser function to codenested=true/code. + +See this demo for an example of how to make this work: + tabs tab name=Toggle box This first tab has a toggle box nested inside it @@ -369,6 +380,9 @@ This second tab has a dropdown nested inside it {{#tag:tab|This dropdown is created via the code#tag:tab/code parser function, since it's not possible to define attributes such as codedropdown/code via the code#tab:/code parser function.|dropdown=true}} /tab +tab index=* block +{{#tag:tab|This toggle box shows up inside {{#tab:|every|each of the|nested=true}} tab{{#tag:tab|s|index=2|nested=true}}, because the containing tab tag has got its index attribute set to codeindex=*/code. It also has a codeblock/code attribute.|openname=Open|closename=Close}} +/tab /tabs = Toggle boxes in dropdowns = diff --git a/Tabs.body.php b/Tabs.body.php index 7383443..677360c 100644 --- a/Tabs.body.php +++ b/Tabs.body.php @@ -60,14 +60,15 @@ $form = $parser-tabsData['tabCount'] === 0 ? $this-insertCSSJS($parser) : ''; // init styles, set the return form tag as $form. ++$parser-tabsData['tabCount']; $names = $parser-tabsData['tabNames']; + $nestAttr = isset($attr['nested']); //adding this attribute will restrict functionality, but allow nested tabs inside toggleboxes $nested = $parser-tabsData['nested']; if (isset($attr['name'])) { $attr['name'] = trim(htmlspecialchars($attr['name'])); // making the name attr safe to use } // Default value for the tab's given index: index attribute's value, or else the index of the tab with the same name as name attribute, or else the tab index - if (!$nested) { + if (!$nested !$nestAttr) { $index = -1; // indices do nothing for non-nested tabs, so don't even bother doing the computations. - } elseif (isset($attr['index']) intval($attr['index']) = count($names)) { + } elseif (isset($attr['index']) (intval($attr['index']) = count($names) || $nestAttr)) { $index = intval($attr['index']); // if the index is given, and it isn't greater than the current index + 1. } elseif (isset($attr['index']) $attr['index'] == '*') { $index = 0; //use wildcard index: this tab's contents shows up for every single tab; @@ -79,7 +80,7 @@ } $classPrefix = ''; - if ($nested) {// Note: This is defined seperately for toggleboxes, because of the different classes required. + if ($nested || $nestAttr) {// Note: This is defined seperately for toggleboxes,
[MediaWiki-commits] [Gerrit] Add nested= attribute to tab tag - change (mediawiki...Tabs)
jenkins-bot has submitted this change and it was merged. Change subject: Add nested= attribute to tab tag .. Add nested= attribute to tab tag now it is possible to make nested toggle boxes or dropdowns have content that depends on the selected tab; simply put a {{#tab:}} or {{#tag:tab}} with |nested=true as last argument inside the toggle/dropdown box. Change-Id: I413ebfc42213ae6e88cd87343cc620fc62016571 --- M README.md M Tabs.body.php M Tabs.php 3 files changed, 33 insertions(+), 8 deletions(-) Approvals: Joeytje50: Looks good to me, approved jenkins-bot: Verified diff --git a/README.md b/README.md index aedad16..d895546 100644 --- a/README.md +++ b/README.md @@ -360,6 +360,17 @@ |dropdown=true}} = Toggle boxes and dropdowns in tab boxes = + +If you want to place a toggle box or a dropdown inside a tab navigation, and want the toggle box to show up for every tab as opposed to just the tab it's nested in, first a parent codelt;tabgt;/code tab must be made, with codeindex=*/code, so that the toggle box won't be recognised as a seperate tab content. + +If you want to place a toggle box or dropdown menu inside a tab menu, you can simply place a codelt;tabgt;/code tag inside the codelt;tabgt;/code tag that functions as a tab. This will restrict toggle boxes and dropdowns to visibility in just one tab though. So, if you want to have a toggle box or dropdown that's visible in every tab, encase it in a codelt;tabgt;/code tag with an codeindex=*/code set to it. + +That way, the outer codelt;tabgt;/code tag will be recognised as a tab container, and the inner one will be recognised as a toggle box or dropdown menu, as desired. The toggle box or dropdown must then also use the [[#General usage information|parser function syntax]]. + +If you want the contents of the toggle box inside the tab menu to be able to change depending on the selected tab, you should use the codenested=true/code attribute on the tag. This can be done by setting the very last argument of the code#tab:/code parser function or the code#tag:tab/code parser function to codenested=true/code. + +See this demo for an example of how to make this work: + tabs tab name=Toggle box This first tab has a toggle box nested inside it @@ -369,6 +380,9 @@ This second tab has a dropdown nested inside it {{#tag:tab|This dropdown is created via the code#tag:tab/code parser function, since it's not possible to define attributes such as codedropdown/code via the code#tab:/code parser function.|dropdown=true}} /tab +tab index=* block +{{#tag:tab|This toggle box shows up inside {{#tab:|every|each of the|nested=true}} tab{{#tag:tab|s|index=2|nested=true}}, because the containing tab tag has got its index attribute set to codeindex=*/code. It also has a codeblock/code attribute.|openname=Open|closename=Close}} +/tab /tabs = Toggle boxes in dropdowns = diff --git a/Tabs.body.php b/Tabs.body.php index 7383443..677360c 100644 --- a/Tabs.body.php +++ b/Tabs.body.php @@ -60,14 +60,15 @@ $form = $parser-tabsData['tabCount'] === 0 ? $this-insertCSSJS($parser) : ''; // init styles, set the return form tag as $form. ++$parser-tabsData['tabCount']; $names = $parser-tabsData['tabNames']; + $nestAttr = isset($attr['nested']); //adding this attribute will restrict functionality, but allow nested tabs inside toggleboxes $nested = $parser-tabsData['nested']; if (isset($attr['name'])) { $attr['name'] = trim(htmlspecialchars($attr['name'])); // making the name attr safe to use } // Default value for the tab's given index: index attribute's value, or else the index of the tab with the same name as name attribute, or else the tab index - if (!$nested) { + if (!$nested !$nestAttr) { $index = -1; // indices do nothing for non-nested tabs, so don't even bother doing the computations. - } elseif (isset($attr['index']) intval($attr['index']) = count($names)) { + } elseif (isset($attr['index']) (intval($attr['index']) = count($names) || $nestAttr)) { $index = intval($attr['index']); // if the index is given, and it isn't greater than the current index + 1. } elseif (isset($attr['index']) $attr['index'] == '*') { $index = 0; //use wildcard index: this tab's contents shows up for every single tab; @@ -79,7 +80,7 @@ } $classPrefix = ''; - if ($nested) {// Note: This is defined seperately for toggleboxes, because of the different classes required. + if ($nested || $nestAttr) {// Note: This is defined seperately for toggleboxes, because of the different classes required.