Difference between revisions of "Template:Segmented control"

From Co-Optitude Wiki
Jump to navigation Jump to search
Line 18: Line 18:
 
{{#ifexpr:{{#var:i}}=1|{{#vardefine:orderClass|rsSegmentFirst}}}}
 
{{#ifexpr:{{#var:i}}=1|{{#vardefine:orderClass|rsSegmentFirst}}}}
 
{{#ifexpr:{{#var:i}}={{#var:segmentCount}}|{{#vardefine:orderClass|rsSegmentLast}}}}
 
{{#ifexpr:{{#var:i}}={{#var:segmentCount}}|{{#vardefine:orderClass|rsSegmentLast}}}}
* orderClass = {{#var:orderClass}}
 
 
{{#vardefine:segment|{{{{{#var:i}}|}}} }}
 
{{#vardefine:segment|{{{{{#var:i}}|}}} }}
* segment = {{#var:segment}}
 
 
{{#vardefine:titleAndImage|{{#explode:{{#var:segment}}|;|0}}}}
 
{{#vardefine:titleAndImage|{{#explode:{{#var:segment}}|;|0}}}}
* imageAndTitle = {{#var:imageAndTitle}}
 
 
{{#vardefine:segmentLink|{{#explode:{{#var:segment}}|;|1}}}}
 
{{#vardefine:segmentLink|{{#explode:{{#var:segment}}|;|1}}}}
* segmentLink = {{#var:segmentLink}}
 
 
{{#vardefine:segmentTitle|{{#explode:{{#var:titleAndImage}}|$|0}}}}
 
{{#vardefine:segmentTitle|{{#explode:{{#var:titleAndImage}}|$|0}}}}
* segmentTitle = {{#var:segmentTitle}}
 
 
{{#vardefine:segmentImage|{{#explode:{{#var:titleAndImage}}|$|1}}}}
 
{{#vardefine:segmentImage|{{#explode:{{#var:titleAndImage}}|$|1}}}}
* segmentImage = {{#var:segmentImage}}
 
 
{{#vardefine:segmentSelected|{{#if:{{#var:segmentLink}}|false|true}}}}
 
{{#vardefine:segmentSelected|{{#if:{{#var:segmentLink}}|false|true}}}}
* {{#var:segmentTitle}} = {{#var:segmentLink}} ({{#var:segmentSelected}})
+
<div class="rsSegment {{#var:orderClass}}{{#if:{{#var:segmentSelected}}| rsSegmentSelected}}">{{#if:{{#var:segmentSelected}}|[[{{#var:segmentLink}}|<div class="rsSegmentFill"><span class="rsSegmentTitle">{{#var:segmentTitle}}</span></div>]]|<div class="rsSegmentFill"><span class="rsSegmentTitle">{{#var:segmentTitle}}</span></div>}}</div>
<div class="rsSegment rsSegmentFirst rsSegmentSelected">
 
{{#if:{{#var:segmentSelected}}|[[{{#var:segmentLink}}|<div class="rsSegmentFill"><span class="rsSegmentTitle">{{#var:segmentTitle}}</span></div>]]|<div class="rsSegmentFill"><span class="rsSegmentTitle">{{#var:segmentTitle}}</span></div>}}
 
</div>
 
 
{{#vardefine:i|{{#expr:{{#var:i}}+1}} }}
 
{{#vardefine:i|{{#expr:{{#var:i}}+1}} }}
 
}}
 
}}
 
</div>
 
</div>
 
</includeonly>
 
</includeonly>

Revision as of 17:24, 28 March 2020

Usage example:

{{SegmentedControl
  |Title;Wiki page name
  |[Image.png]Title;Wiki page name
  |Selected title
  |etc}}