Module:Tabs: Difference between revisions

Want an adless experience? Log in or Create an account.
use Args.fromFrame
(yeah passing args around like that is a bad idea. (not gonna fix it rn tho))
(use Args.fromFrame)
Line 182: Line 182:


function p.tabs( frame )
function p.tabs( frame )
   local args = Args.parse( frame.args )
   local args = Args.fromFrame( frame )
   local tabs = TabContainer.new( args:values() )
   local tabs = TabContainer.new( args )


   if args.left then
   if args.left then
     local left = tabs:leftTabs( args.left:values() )
     local left = tabs:leftTabs( args.left )
     for _, leftArgs in ipairs( args.left ) do
     for _, leftArgs in ipairs( args.left ) do
       tabArgs = leftArgs:values()
       tabArgs = leftArgs
       tabArgs.selection = leftArgs:val()
       tabArgs.selection = Args.getValue( leftArgs )
       left:addTab( tabArgs )
       left:addTab( tabArgs )
     end
     end
Line 195: Line 195:


   if args.top then
   if args.top then
     local topArgs = args.top:values()
     local topArgs = args.top
     if args.left and not topArgs.selector then topArgs.selector = 1 end -- default to 2D behavior if both sets are present
     if args.left and not topArgs.selector then topArgs.selector = 1 end -- default to 2D behavior if both sets are present
     local top = tabs:topTabs( topArgs )
     local top = tabs:topTabs( topArgs )
     for _, topArgs in ipairs( args.top ) do
     for _, topArgs in ipairs( args.top ) do
       tabArgs = topArgs:values()
       tabArgs = topArgs
       tabArgs.selection = topArgs:val()
       tabArgs.selection = Args.getValue( topArgs )
       top:addTab( tabArgs )
       top:addTab( tabArgs )
     end
     end
   end
   end
    
    
   for k, v in pairs( args.content or {} ) do -- order doesn't matter here since only one is displayed at a time
   for contentId, contentArgs in pairs( args.content or {} ) do -- order doesn't matter here since only one is displayed at a time
     local contentArgs = v:values()
     contentArgs = Args.getTable( contentArgs )
     contentArgs.contentId = k
     contentArgs.contentId = contentId
     contentArgs.content = v:val()
     contentArgs.content = Args.getValue( contentArgs )
     tabs:addContent( contentArgs )
     tabs:addContent( contentArgs )
   end
   end