Modul:Vorlage:Auflistung: Unterschied zwischen den Versionen

K
9 Versionen von wikipedia:Modul:Vorlage:Auflistung importiert
(2020-11-02)
K (9 Versionen von wikipedia:Modul:Vorlage:Auflistung importiert)
 
(2 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt)
Zeile 1: Zeile 1:
local HorizontalList = { suite  = "HorizontalList",
local HorizontalList = { suite  = "HorizontalList",
                         serial = "2020-11-02",
                         serial = "2021-02-05",
                         item  = 100938243 }
                         item  = 100938243 }
--[=[
--[=[
Zeile 9: Zeile 9:


local CSS      = { classesBlock  = { },
local CSS      = { classesBlock  = { },
                  classesNowrap = { },
                   classesPrefix = { },
                   classesPrefix = { },
                   classesSep    = { } }
                   classesSep    = { } }
Zeile 15: Zeile 16:




HorizontalList.f = function ( all, ahead, altogether, apart, frame )
local fix = function ( at )
    for k, v in pairs( CSS.classesNowrap ) do
        at:addClass( v )
    end -- for k, v
end -- fix()
 
 
 
HorizontalList.f = function ( all, ahead, altogether, access, alien,
                              apart, frame )
     -- Generate horizontal list from wikitext
     -- Generate horizontal list from wikitext
     -- Parameter:
     -- Parameter:
     --    all         -- string, with wikitext
     --    all         -- string, with wikitext
     --                     each line starting with one of * or #
     --                   each line starting with one of * or #
     --    ahead       -- string, to prefix if desired
     --    ahead       -- string, to prefix if desired
     --    altogether   -- true, if nowrap around each regular item
     --    altogether -- true, if nowrap around each regular item
     --    apart       -- string, with separator, if desired
    --    access      -- string, with fragment, if desired
     --    frame       -- object, if available
    --    alien      -- string, with language code, if desired
     --    apart       -- string, with separator, if desired
     --    frame       -- object, if available
     -- Returns string
     -- Returns string
     local r
     local r
Zeile 54: Zeile 66:
                                         start,
                                         start,
                                         altogether,
                                         altogether,
                                        access,
                                        alien,
                                         apart,
                                         apart,
                                         frame )
                                         frame )
Zeile 72: Zeile 86:




HorizontalList.fiat = function ( all, advance, ahead,
HorizontalList.fiat = function ( all, advance, ahead, altogether,
                                 altogether, apart, frame )
                                 access, alien, apart, frame )
     -- Generate horizontal list from item sequence
     -- Generate horizontal list from item sequence
     -- Parameter:
     -- Parameter:
     --    all         -- table, with sequence of items
     --    all         -- table, with sequence of items
     --                     each item is a string or a mw.html object
     --                   each item is a string or a mw.html object
     --    ahead       -- string, to prefix if desired
     --    ahead       -- string, to prefix if desired
     --    advance     -- true, if ordered list requested
     --    advance     -- true, if ordered list requested
     --    altogether   -- true, if nowrap around each item
     --    altogether -- true, if nowrap around each item
     --    apart       -- string, with separator, if desired
    --    access      -- string, with fragment, if desired
     --    frame       -- object, if available
    --    alien      -- string, with language code, if desired
     --    apart       -- string, with separator, if desired
     --    frame       -- object, if available
     -- Returns string
     -- Returns string
     local r
     local r
Zeile 98: Zeile 114:
                 ou:addClass( v )
                 ou:addClass( v )
             end -- for k, v
             end -- for k, v
            if CSS.style then
                ou:cssText( CSS.style )
            end
            if CSS.css then
                ou:css( CSS.css )
            end
            if type( access ) == "string" then
                s = mw.text.trim( access )
                if s ~= "" then
                    ou:attr( "id", s )
                end
            end
            if alien then
                s = mw.text.trim( alien )
                if s ~= "" then
                    ou:attr( "lang", s )
                end
            end
             if type( apart ) == "string" then
             if type( apart ) == "string" then
                 es = mw.html.create( "span" )
                 es = mw.html.create( "span" )
Zeile 123: Zeile 157:
                 else
                 else
                     e:wikitext( tostring( s ) )
                     e:wikitext( tostring( s ) )
                end
                if CSS.styleItem then
                    e:cssText( CSS.styleItem )
                 end
                 end
                 if es  and  i < #all then
                 if es  and  i < #all then
Zeile 128: Zeile 165:
                 end
                 end
                 if altogether then
                 if altogether then
                     e:css( "white-space", "nowrap" )
                     fix( e )
                 end
                 end
                 ou:newline()
                 ou:newline()
Zeile 147: Zeile 184:
             r = all[ 1 ]
             r = all[ 1 ]
             if altogether then
             if altogether then
                 if type( r ) == "table" then
                 if type( r ) ~= "table" then
                    r:css( "white-space", "nowrap" )
                else
                     r = mw.html.create( "span" )
                     r = mw.html.create( "span" )
                              :css( "white-space", "nowrap" )
                               :wikitext( tostring( r ) )
                               :wikitext( tostring( r ) )
                 end
                 end
                fix( r )
             end
             end
             r = tostring( r )
             r = tostring( r )
Zeile 167: Zeile 203:
     -- Parameter:
     -- Parameter:
     --    arglist  -- table, with optional components
     --    arglist  -- table, with optional components
    --                styleItem    -- style per item
    --                                  -- string
     --                styles        -- templatestyles page
     --                styles        -- templatestyles page
     --                                  -- string, with name
     --                                  -- string, with name
Zeile 173: Zeile 211:
     --                                  -- string, with class(es)
     --                                  -- string, with class(es)
     --                                  -- table, with particular mapping
     --                                  -- table, with particular mapping
     --                classesPrefix   -- class(es) for prefix element
    --                classesNowrap -- class(es) for nowrap element
    --                                  -- string, with class(es)
    --                                  -- table, with particular mapping
     --                classesPrefix -- class(es) for prefix element
     --                                  -- string, with class(es)
     --                                  -- string, with class(es)
     --                                  -- table, with particular mapping
     --                                  -- table, with particular mapping
Zeile 219: Zeile 260:
         if s  and  s:match( ".+:.+%.css$") then
         if s  and  s:match( ".+:.+%.css$") then
             CSS.styles = s
             CSS.styles = s
        end
        val = arglist.style
        s  = type( val )
        if s == "string" then
            s = mw.text.trim( val )
            if s ~= "" then
                CSS.style = s
            end
        elseif s == "table" then
            CSS.css = val
        end
        val = arglist.styleItem
        if type( val ) == "string" then
            s = mw.text.trim( val )
            if s ~= "" then
                CSS.styleItem = s
            end
         end
         end
     end
     end
Zeile 290: Zeile 348:
     HorizontalList.first( { styles        = frame.args.styles,
     HorizontalList.first( { styles        = frame.args.styles,
                             classesBlock  = frame.args.classesBlock,
                             classesBlock  = frame.args.classesBlock,
                            classesNowrap = frame.args.classesNowrap,
                             classesPrefix = frame.args.classesPrefix,
                             classesPrefix = frame.args.classesPrefix,
                             classesSep    = frame.args.classesSep } )
                             classesSep    = frame.args.classesSep,
                            style        = frame.args.style,
                            styleItem    = frame.args.styleItem } )
     return HorizontalList.f( frame.args[ 1 ],
     return HorizontalList.f( frame.args[ 1 ],
                             frame.args.prefix,
                             frame.args.prefix,
                             frame.args.nowrap == "1",
                             frame.args.nowrap == "1",
                            frame.args.id,
                            frame.args.lang,
                             frame.args.sep,
                             frame.args.sep,
                             frame )
                             frame )