Module:Tabs: Difference between revisions

Want an adless experience? Log in or Create an account.
determine default content based on default tabs, rather than specifying it. might add support for 'nojs' content later.
m (preprocess didn't help, as expected. another theory, adding a newline)
(determine default content based on default tabs, rather than specifying it. might add support for 'nojs' content later.)
Line 69: Line 69:
   if self.args.width then container:css( 'width', self.args.width .. 'px' ) end
   if self.args.width then container:css( 'width', self.args.width .. 'px' ) end
   if self.args.height then container:css( 'height', self.args.height .. 'px' ) end
   if self.args.height then container:css( 'height', self.args.height .. 'px' ) end
  local defaults = {}


   if self.tabsLeft then
   if self.tabsLeft then
Line 79: Line 81:
       :css( 'margin-left', '-' .. tostring( width + 10 ) .. 'px' )
       :css( 'margin-left', '-' .. tostring( width + 10 ) .. 'px' )
       :wikitext( self.tabsLeft:render() )
       :wikitext( self.tabsLeft:render() )
    if self.tabsLeft.defaultTab > 0 then
      defaults[self.tabsLeft.selector] = self.tabsLeft.tabs[self.tabsLeft.defaultTab].selection
    end
   end
   end


Line 86: Line 92:
       :addClass( 'zdw-tabcontainer__tabset--top' )
       :addClass( 'zdw-tabcontainer__tabset--top' )
       :wikitext( self.tabsTop:render() )
       :wikitext( self.tabsTop:render() )
    if self.tabsTop.defaultTab > 0 then
      defaults[self.tabsTop.selector] = self.tabsTop.tabs[self.tabsTop.defaultTab].selection
    end
   end
   end
  local defaultContent = ''
  if defaults[0] then defaultContent = defaultContent .. defaults[0] end
  if defaults[1] then defaultContent = defaultContent .. ' ' .. defaults[1] end


   for _, c in ipairs( self.contents ) do
   for _, c in ipairs( self.contents ) do
    if c.contentId == defaultContent then c.default = true end
     container:wikitext( c:render() )
     container:wikitext( c:render() )
   end
   end
Line 145: Line 160:


   if self.args.default then
   if self.args.default then
    tab:addClass( 'active' )
     tab:attr( 'data-tab-default', 'true' )
     tab:attr( 'data-tab-default', 'true' )
   end
   end
Line 166: Line 182:
     :wikitext( '\n' .. self.content )
     :wikitext( '\n' .. self.content )


   if self.contentId == 'default' then
   if self.default then
     content:addClass( 'default' )
     content:addClass( 'default' )
   end
   end