Module:InfoboxProto: Difference between revisions

no edit summary
No edit summary
No edit summary
Tag: Manual revert
 
(3 intermediate revisions by the same user not shown)
Line 31: Line 31:


     -- Adds a normal row
     -- Adds a normal row
     function addField(param, field_name, double, collapsed)
     function addField(param, field_name, double, field_value, collapsed)
         field_value = args[param];
         if args[param] ~= nil or field_value ~= nil then
        if field_value ~= nil then
             local row = infobox:tag('div'):addClass('infobox-row');
             local row = infobox:tag('div'):addClass('infobox-row');
             if field_name == nil then
             if field_name == nil then
                 field_name = titleCase(param);
                 field_name = titleCase(param);
            end
            if field_value == nil then
                field_value = args[param];
             end
             end
             row:tag('div'):addClass('infobox-row-title'):tag('span'):wikitext(field_name);
             row:tag('div'):addClass('infobox-row-title'):tag('span'):wikitext(field_name);
Line 54: Line 56:
         end
         end
         if double == true then
         if double == true then
             addField2(param, field_name)
             addField2(param, field_name, collapsed)
         end
         end
     end
     end


     -- Adds a row with 2 columns
     -- Adds a row with 2 columns
     function addField2(param, field_name)
     function addField2(param, field_name, collapsed)
         if args[param .. '1'] ~= nil and args[param .. '2'] ~= nil then
         if args[param .. '1'] ~= nil and args[param .. '2'] ~= nil then
             local row = infobox:tag('div'):addClass('infobox-row'):addClass('infobox-double-row');
             local row = infobox:tag('div'):addClass('infobox-row'):addClass('infobox-double-row');
Line 66: Line 68:
             end
             end
             row:tag('div'):addClass('infobox-row-title'):wikitext(field_name);
             row:tag('div'):addClass('infobox-row-title'):wikitext(field_name);
             row:tag('div'):addClass('infobox-row-content'):tag('span'):wikitext(args[param .. '1']);
             for i=1, 2, 1 do
            row:tag('div'):addClass('infobox-row-content'):tag('span'):wikitext(args[param .. '2']);
                local inner = row:tag('div'):addClass('infobox-row-content'):tag('div')
                if collapsed then
                    inner:addClass('mw-collapsible mw-collapsed')
                end
                inner:wikitext(args[param .. i]);
            end
         end
         end
     end
     end
Line 77: Line 84:
                 addField2(v.id, v.localize)
                 addField2(v.id, v.localize)
             else
             else
                 addField(v.id, v.localize, v.dual, v.collapsed)
                 addField(v.id, v.localize, v.dual, v.value, v.collapsed)
             end
             end
         end
         end