Module:Navbox: Difference between revisions

From Test Wiki
76 bytes added ,  14 March 2014
Update from sandbox
(that was not "show preview" button)
(Update from sandbox)
Line 16: Line 16:
function trim(s)
function trim(s)
     return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
     return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
end
function addNewline(s)
    if s:match('^[*:;#]') or s:match('^{|') then
        return '\n' .. s ..'\n'
    else
        return s
    end
end
end


Line 25: Line 33:
                 .css('height', '2px')
                 .css('height', '2px')
                 .tag('td')
                 .tag('td')
                .attr('colspan',2)
     end
     end
      
      
Line 72: Line 81:
         .attr('colspan', titleColspan)
         .attr('colspan', titleColspan)
   
   
    renderNavBar(titleCell)
    renderNavBar(titleCell)
 
    titleCell
    titleCell
         .tag('div')
         .tag('div')
             .addClass(args.titleclass)
             .addClass(args.titleclass)
             .css('font-size', '110%')
             .css('font-size', '110%')
             .newline()
             .wikitext(addNewline(args.title))
            .wikitext(args.title)
end
end


Line 122: Line 130:
function renderAboveRow(tbl)
function renderAboveRow(tbl)
     if not args.above then return end
     if not args.above then return end
 
     addTableRow(tbl)
     addTableRow(tbl)
         .tag('td')
         .tag('td')
Line 131: Line 139:
             .attr('colspan', getAboveBelowColspan())
             .attr('colspan', getAboveBelowColspan())
             .tag('div')
             .tag('div')
                 .newline()
                 .wikitext(addNewline(args.above))
                .wikitext(args.above)
end
end


function renderBelowRow(tbl)
function renderBelowRow(tbl)
     if not args.below then return end
     if not args.below then return end
   
 
     addTableRow(tbl)
     addTableRow(tbl)
         .tag('td')
         .tag('td')
Line 146: Line 153:
             .attr('colspan', getAboveBelowColspan())
             .attr('colspan', getAboveBelowColspan())
             .tag('div')
             .tag('div')
                 .newline()
                 .wikitext(addNewline(args.below))
                .wikitext(args.below)
end
end


Line 174: Line 180:
                 .attr('rowspan', 2 * #listnums - 1)
                 .attr('rowspan', 2 * #listnums - 1)
                 .tag('div')
                 .tag('div')
                     .newline()
                     .wikitext(addNewline(args.imageleft))
                    .wikitext(args.imageleft)
     end
     end
   
   
Line 222: Line 227:
         if isOdd then evenOdd = args.evenodd or 'odd' else evenOdd = args.evenodd or 'even' end
         if isOdd then evenOdd = args.evenodd or 'odd' else evenOdd = args.evenodd or 'even' end
     end
     end
   
 
     listCell
     listCell
         .css('padding', '0px')
         .css('padding', '0px')
Line 233: Line 238:
         .tag('div')
         .tag('div')
             .css('padding', (listnum == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
             .css('padding', (listnum == 1 and args.list1padding) or args.listpadding or '0em 0.25em')
             .newline()
             .wikitext(addNewline(args['list' .. listnum]))
            .wikitext(args['list' .. listnum])


     if listnum == 1 and args.image then
     if listnum == 1 and args.image then
Line 246: Line 250:
                 .attr('rowspan', 2 * #listnums - 1)
                 .attr('rowspan', 2 * #listnums - 1)
                 .tag('div')
                 .tag('div')
                     .newline()
                     .wikitext(addNewline(args.image))
                    .wikitext(args.image)
     end
     end
end
end
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.