Jump to content

Module:Navbox: Difference between revisions

602 bytes added ,  11 years ago
fix title centering
m>Toohool
m (htmlbuilder moved)
m>Toohool
(fix title centering)
Line 81: Line 81:
   
   
function renderNavBar(titleCell)
function renderNavBar(titleCell)
     local addStateLinkPlaceholder = false
    -- Depending on the presence of the navbar and/or show/hide link, we may need to add a spacer div on the left
     if args.navbar == 'plain' or args.navbar == 'off' or (not args.name and (border == 'subgroup' or border == 'child' or border == 'none')) then
    -- or right to keep the title centered.
         if args.navbar == 'off' then
     local spacerSide = nil
            addStateLinkPlaceholder = (args.state == 'plain')
 
        else
     if args.navbar == 'off' then
            addStateLinkPlaceholder = (args.state ~= 'plain')
        -- No navbar, and client wants no spacer, i.e. wants the title to be shifted to the left. If there's
        end
        -- also no show/hide link, then we need a spacer on the right to achieve the left shift.
        if args.state == 'plain' then spacerSide = 'right' end
    elseif args.navbar == 'plain' or args.navbar == 'off' or (not args.name and (border == 'subgroup' or border == 'child' or border == 'none')) then
         -- No navbar. Need a spacer on the left to balance out the width of the show/hide link.
        if args.state ~= 'plain' then spacerSide = 'left' end
     else
     else
        -- Will render navbar (or error message). If there's no show/hide link, need a spacer on the right
        -- to balance out the width of the navbar.
        if args.state == 'plain' then spacerSide = 'right' end
         if args.name then
         if args.name then
             titleCell.wikitext(mw.getCurrentFrame():expandTemplate{ title = 'navbar', args = {  
             titleCell.wikitext(mw.getCurrentFrame():expandTemplate{ title = 'navbar', args = {  
Line 102: Line 110:
                     .css('white-space', 'nowrap')
                     .css('white-space', 'nowrap')
                     .wikitext('Error: No name provided')
                     .wikitext('Error: No name provided')
            addStateLinkPlaceholder = (args.state == 'plain')
         end
         end
     end
     end
      
      
     if addStateLinkPlaceholder then
    -- Render the spacer div.
     if spacerSide then
         titleCell
         titleCell
             .tag('span')
             .tag('span')
                 .css('float', 'right')
                 .css('float', spacerSide)
                 .css('width', '6em')
                 .css('width', '6em')
                 .wikitext(' ')
                 .wikitext(' ')
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.