Module:Clade/hidden
local p = {}
 
 function p.hidden(frame)
     
     local id = mw.getCurrentFrame():getParent().args['id'] or &quot;&quot;
     local mode = mw.getCurrentFrame():getParent().args['mode'] or &quot;right&quot;
     local expandSymbol = mw.getCurrentFrame():getParent().args['expand-symbol'] or &quot;&amp;#8862;&quot;
     local collapseSymbol = mw.getCurrentFrame():getParent().args['collapse-symbol'] or &quot;&amp;#8863;&quot;
     local expandText = mw.getCurrentFrame():getParent().args['expand-text'] or &quot;&quot;
     local collapseText = mw.getCurrentFrame():getParent().args['collapse-text'] or &quot;&quot;
     local initialStateExpanded = mw.getCurrentFrame():getParent().args['expanded'] or &quot;false&quot;
     if mw.getCurrentFrame():getParent().args['expand-symbol'] == &quot;none&quot; then
         expandSymbol = expandText
     else
     	expandSymbol = expandSymbol .. expandText
     end
     if mw.getCurrentFrame():getParent().args['collapse-symbol'] == &quot;none&quot; then
         collapseSymbol = collapseText
     else
 		collapseSymbol = collapseSymbol .. collapseText
     end
     
     -- default is content collapsed
     local contentState = &quot; mw-collapsed&quot; -- class to collapse content at start
     local collapseSymbolState = &quot; mw-collapsed&quot;
     local expandSymbolState = &quot;&quot;
     if initialStateExpanded  == &quot;true&quot; or initialStateExpanded  == &quot;yes&quot; then
        contentState = &quot;&quot;
        collapseSymbolState =  &quot;&quot;
        expandSymbolState = &quot; mw-collapsed&quot; 
     end
     	
 	
     -- collapsible element containing the EXPAND SYMBOL and/or text
     local expandSymbolString = '&lt;td class=&quot;nomobile&quot; style=&quot;padding:0 0 0.0em 0;&quot;&gt;' 
                 .. '&lt;div class=&quot;mw-collapsible' .. expandSymbolState .. '&quot; id=&quot;mw-customcollapsible-expandSymbol' .. id .. '&quot;&gt;'
                 .. '&lt;div class=&quot;mw-collapsible-content mw-customtoggle-expandSymbol' .. id .. '&quot;&gt;'
                 .. '&lt;span class=&quot;mw-customtoggle-myClade' .. id 
                 ..             ' mw-customtoggle-collapseSymbol' .. id 
                 ..             ' mw-customtoggle-expandSymbol' .. id 
                 ..    '&quot; style=&quot;font-size:100%;&quot;&gt;' .. expandSymbol .. '&lt;/span&gt;'
                 .. '&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;'
     
     -- collapsible element containing the CLADE CONTENT 
     local clade = require( 'Module:Clade' )
     local contentString = '&lt;td style=&quot;padding:0;&quot; class=&quot;clade-interactive&quot; &gt;'
                 .. '&lt;div class=&quot;mw-collapsible' .. contentState .. '&quot; id=&quot;mw-customcollapsible-myClade' .. id .. '&gt;'
                 .. '&lt;div class=&quot;mw-collapsible-content mw-customtoggle-NOT_ON_CONTENT&quot; &gt;' -- don't toggle on the content
                 
                 .. '\n' .. clade.main(frame)  -- important to start wikitext tables on new line
                 .. '&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;'
     
     -- collapsible element containing the COLLAPSE SYMBOL and/or text
     local collapseSymbolString = '&lt;td class=&quot;nomobile&quot; style=&quot;padding:0 0 0.0em 0;&quot;&gt;'
                 .. '&lt;div class=&quot;mw-collapsible' .. collapseSymbolState .. '&quot; id=&quot;mw-customcollapsible-collapseSymbol' .. id .. '&quot;&gt;'
                 .. '&lt;div class=&quot;mw-collapsible-content mw-customtoggle-collapseSymbol' .. id .. '&quot; &gt;'
                 .. '&lt;span class=&quot;mw-customtoggle-expandSymbol' .. id 
                             .. ' mw-customtoggle-myClade' .. id 
                             .. ' mw-customtoggle-collapseSymbol' .. id 
                             .. ' &quot; style=&quot;font-size:100%;&quot; &gt;' .. collapseSymbol .. '&lt;/span&gt;'
                             .. '&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;'
 
 
 	local tableStyle = frame.args.style or &quot;&quot;
 	if tableStyle == '{{{style}}}' then tableStyle = &quot;&quot; end
  	local cladeString = '&lt;table style=&quot;border-spacing:0;margin:0;'..tableStyle ..'&quot;&gt;&lt;tr&gt;'
     cladeString = cladeString .. expandSymbolString 
     if mode == &quot;left&quot; then
     	cladeString = cladeString .. collapseSymbolString
     end
     cladeString = cladeString .. contentString 
     if mode == &quot;right&quot; then
     	cladeString = cladeString .. collapseSymbolString
     end
     -- Note: if we want collapse string left and right it needs an extra element with a different id
     cladeString = cladeString ..  '&lt;/tr&gt;&lt;/table&gt;'
 
 
 return p.templateStyle( frame, &quot;Clade hidden/styles.css&quot; ) .. cladeString
 end
 
 function p.toggle(frame)
 	
 	if 1==2 then return 'some text' end
 	
 	--local toggleSymbol = 'toggle all'
 	local toggleSymbol = mw.getCurrentFrame():getParent().args['button'] or &quot;&quot;
 
 	local toggleString = '&lt;div class=&quot;'
                 
     local i=0
     while 	i &lt; 20 do  -- limit on number of toggle elements controlled by the trigger button
     	i = i + 1 -- so we start with 1
 		local target = mw.getCurrentFrame():getParent().args['id'..tostring(i)] 
 	    
 	    -- add classes for the three elements of each target: expand symbol, collapse symbol and contents
 	    if target ~= nil then
             toggleString = toggleString .. ' mw-customtoggle-myClade' .. target 
                 ..             ' mw-customtoggle-collapseSymbol' .. target 
                 ..             ' mw-customtoggle-expandSymbol' .. target 
         end
     end
   
  
  toggleString = toggleString  ..  '&quot;&gt;' .. toggleSymbol .. '&lt;/div&gt;'
 
   return toggleString
 end
 
 
 -- &lt;templatestyles src=&quot;Clade hidden/styles.css&quot;&gt;&lt;/templatestyles&gt;
 function p.templateStyle( frame, src )
    return frame:extensionTag( 'templatestyles', '', { src = src } );
 end