Module:Tabs: Difference between revisions

Want an adless experience? Log in or Create an account.
rename a couple functions and add shortcut functions for adding tab+content in 1D scenario
m (default args to {})
(rename a couple functions and add shortcut functions for adding tab+content in 1D scenario)
Line 45: Line 45:
end
end


function TabContainer:content( args )
function TabContainer:addTabLeftWithContent( args )
  -- normalize args so they can just be passed to everything. definitely a bad idea but...
  args.selector = getRequiredArg( args, 'contentId', 'TabContainer:addTabLeft' )
  self:tabsLeft( args ):addTab( args )
  self:addContent( args )
end
 
function TabContainer:addTabTopWithContent( args )
  -- normalize args so they can just be passed to everything. definitely a bad idea but...
  args.selector = getRequiredArg( args, 'contentId', 'TabContainer:addTabTop' )
  self:tabsTop( args ):addTab( args )
  self:addContent( args )
end
 
function TabContainer:addContent( args )
   self.contents[#self.contents + 1] = TabContent.new( args )
   self.contents[#self.contents + 1] = TabContent.new( args )
end
end
Line 95: Line 109:
end
end


function TabSet:tab( args )
function TabSet:addTab( args )
   local index = #self.tabs + 1
   local index = #self.tabs + 1
   if index == self.defaultTab then args.default = true end
   if index == self.defaultTab then args.default = true end
Line 176: Line 190:
       tabArgs = leftArgs:values()
       tabArgs = leftArgs:values()
       tabArgs.selection = leftArgs:val()
       tabArgs.selection = leftArgs:val()
       left:tab( tabArgs )
       left:addTab( tabArgs )
     end
     end
   end
   end
Line 187: Line 201:
       tabArgs = topArgs:values()
       tabArgs = topArgs:values()
       tabArgs.selection = topArgs:val()
       tabArgs.selection = topArgs:val()
       top:tab( tabArgs )
       top:addTab( tabArgs )
     end
     end
   end
   end
Line 195: Line 209:
     contentArgs.contentId = k
     contentArgs.contentId = k
     contentArgs.content = v:val()
     contentArgs.content = v:val()
     tabs:content( contentArgs )
     tabs:addContent( contentArgs )
   end
   end