Difference between revisions of "Template:Segmented control"

From Co-Optitude Wiki
Jump to navigation Jump to search
 
(27 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
Usage example:
 
Usage example:
 
<pre>
 
<pre>
{{SegmentedControl
+
{{Segmented control
   |Title;Wiki page name
+
   |Titles=Title 1;Title 2;Title 3
  |Title$icon.png;Wiki page name
+
   |Icons=rsIconCSSClassName;;rsIconCSSClassName
   |Selected title
+
   |Links=Name of page;Name of page;}}
   |etc}}
 
 
</pre>
 
</pre>
 +
Segments without links will be assumed to be selected. Missing icon classes will show segments without icons.
 
</noinclude>
 
</noinclude>
<includeonly>
+
<includeonly><div class="rsToggleContainer">{{#vardefine:i|0}}{{#while:|{{#vardefine:segmentTitle|{{#explode:{{{Titles|}}}|;|{{#var:i}} }} }}{{#var:segmentTitle}}
{{#vardefine:segmentCount|0}}
+
    |<nowiki/>{{#vardefine:segmentImage|{{#explode:{{{Icons|}}}|;|{{#var:i}} }} }}{{#vardefine:segmentLink|{{#explode:{{{Links|}}}|;|{{#var:i}} }} }}{{#vardefine:segmentClasses|rsSegment {{#if:{{#var:segmentLink}}||rsSegmentSelected}}}}{{#vardefine:segmentIconHTML|{{#if:{{#var:segmentImage}}|<span class="rsSegmentIcon {{#var:segmentImage}}"></span>}}}}{{#vardefine:segmentFillHTML|<div class="rsSegmentFill"><span class="rsSegmentTitle">{{#var:segmentIconHTML}} <span class="rsSegmentTitleText">{{#var:segmentTitle}}</span></span></div>}}<div class="{{#var:segmentClasses}}">{{#if:{{#var:segmentLink}}|[[{{#var:segmentLink}}|{{#var:segmentFillHTML}}]]|{{#var:segmentFillHTML}}}}</div>{{#vardefine:i|{{#expr:{{#var:i}}+1}}}}}}</div></includeonly>
{{#vardefine:i|1}}
 
{{#while:|{{#if:{{{{{#var:i}}|}}}|true}}|<nowiki/>{{#vardefine:segmentCount|{{#expr:{{#var:segmentCount}}+1}}}}
 
{{#vardefine:i|{{#expr:{{#var:i}}+1}}}}
 
}}
 
<div class="rsToggleContainer" style="text-align: center;">
 
{{#vardefine:i|1}}
 
{{#while:|{{#ifexpr:{{#var:i}}<={{#var:segmentCount}}|true}}
 
|<nowiki />
 
  {{#vardefine:orderClass|rsSegmentMiddle }}
 
  {{#ifexpr:{{#var:i}}=1|{{#vardefine:orderClass|rsSegmentFirst}}}}
 
  {{#ifexpr:{{#var:i}}={{#var:segmentCount}}|{{#vardefine:orderClass|rsSegmentLast}}}}
 
  {{#vardefine:segment|{{{{{#var:i}}|}}}}}
 
  {{#vardefine:titleAndImage|{{#explode:{{#var:segment}}|;|0}} }}
 
  {{#vardefine:segmentLink|{{#explode:{{#var:segment}}|;|1}} }}
 
  {{#vardefine:segmentTitle|{{#explode:{{#var:titleAndImage}}|$|0}} }}
 
  {{#vardefine:segmentImage|{{#explode:{{#var:titleAndImage}}|$|1}} }}
 
  {{#vardefine:segmentSelected|{{#if:{{#var:segmentLink}}||true}} }}
 
  {{#vardefine:segmentClasses|rsSegment {{#var:orderClass}} {{#if:{{#var:segmentSelected}}|rsSegmentSelected}}}}
 
  {{#vardefine:segmentIconHTML|{{#if:{{#var:segmentImage}}|<span class="rsSegmentIcon">[[File:{{#var:segmentImage}}|20px|none|link={{#var:segmentLink}}]]</span>}} }}
 
  {{#vardefine:segmentFillHTML|<div class="rsSegmentFill"><span class="rsSegmentTitle">{{#var:segmentIconHTML}}}}<span class="rsSegmentTitleText">{{#var:segmentTitle}}</span></span></div>}}
 
<div class="{{#var:segmentClasses}}">{{#if:{{#var:segmentSelected}}|{{#var:segmentFillHTML}}|[[{{#var:segmentLink}}|{{#var:segmentFillHTML}}]]}}</div>{{#vardefine:i|{{#expr:{{#var:i}}+1}} }} }}</div></includeonly>
 

Latest revision as of 06:01, 25 April 2020

Usage example:

{{Segmented control
  |Titles=Title 1;Title 2;Title 3
  |Icons=rsIconCSSClassName;;rsIconCSSClassName
  |Links=Name of page;Name of page;}}

Segments without links will be assumed to be selected. Missing icon classes will show segments without icons.