Modul:Vorlage:Auflistung: Unterschied zwischen den Versionen

K
9 Versionen von wikipedia:Modul:Vorlage:Auflistung importiert
(2020-10-23)
K (9 Versionen von wikipedia:Modul:Vorlage:Auflistung importiert)
 
(6 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
local HorizontalList = { suite  = "HorizontalList",
local HorizontalList = { suite  = "HorizontalList",
                         serial = "2020-10-23",
                         serial = "2021-02-05",
                         item  = 0 }
                         item  = 100938243 }
-- Horizontal list of items by HTML/CSS list
--[=[
Horizontal list of items by HTML/CSS list
]=]






local CSS      = { classesBlock = { },
local CSS      = { classesBlock = { },
                   classesSep   = { } }
                  classesNowrap = { },
                  classesPrefix = { },
                   classesSep   = { } }
local Failsafe = HorizontalList
local Failsafe = HorizontalList






HorizontalList.f = function ( all, 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 #
     --    altogether   -- true, if nowrap around each regular item
    --    ahead      -- string, to prefix if desired
     --    apart       -- string, with separator, if desired
     --    altogether -- true, if nowrap around each regular item
     --    frame       -- object, if available
    --    access      -- string, with fragment, if desired
    --    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 42: Zeile 58:
             end -- for i
             end -- for i
             if got then
             if got then
                local start
                if type( ahead ) == "string"  and  ahead ~= "" then
                    start = ahead
                end
                 r = HorizontalList.fiat( got,
                 r = HorizontalList.fiat( got,
                                         list,
                                         list,
                                        start,
                                         altogether,
                                         altogether,
                                        access,
                                        alien,
                                         apart,
                                         apart,
                                         frame )
                                         frame )
Zeile 63: Zeile 86:




HorizontalList.fiat = function ( all, advance, altogether, apart, frame )
HorizontalList.fiat = function ( all, advance, ahead, altogether,
                                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
     --    advance     -- true, if ordered list requested
    --    ahead      -- string, to prefix if desired
     --    altogether   -- true, if nowrap around each item
     --    advance     -- true, if ordered list requested
     --    apart       -- string, with separator, if desired
     --    altogether -- true, if nowrap around each item
     --    frame       -- object, if available
    --    access      -- string, with fragment, if desired
    --    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 87: 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" )
                             :wikitext( apart )
                             :node( mw.html.create( "span" )
                                          :attr( "aria-hidden", "true" )
                                          :wikitext( apart ) )
                 for k, v in pairs( CSS.classesSep ) do
                 for k, v in pairs( CSS.classesSep ) do
                     es:addClass( v )
                     es:addClass( v )
                 end -- for k, v
                 end -- for k, v
            end
            if type( ahead ) == "string" then
                e = mw.html.create( "li" )
                          :wikitext( ahead )
                for k, v in pairs( CSS.classesPrefix ) do
                    e:addClass( v )
                end -- for k, v
                ou:newline()
                  :node( e )
             end
             end
             for i = 1, #all do
             for i = 1, #all do
Zeile 101: 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 106: Zeile 165:
                 end
                 end
                 if altogether then
                 if altogether then
                     e:css( "white-space", "nowrap" )
                     fix( e )
                 end
                 end
                 ou:newline()
                 ou:newline()
Zeile 125: 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 145: 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
     --                                  -- table, with title object
     --                                  -- table, with title object
     --                classesBlock  -- class(es) for block element
     --                classesBlock  -- class(es) for block element
    --                                  -- string, with class(es)
    --                                  -- table, with particular mapping
    --                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 194: 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 263: Zeile 346:
p.f = function ( frame )
p.f = function ( frame )
     -- Template call
     -- Template call
     HorizontalList.first( { styles       = frame.args.styles,
     HorizontalList.first( { styles       = frame.args.styles,
                             classesBlock = frame.args.classesBlock,
                             classesBlock = frame.args.classesBlock,
                             classesSep   = frame.args.classesSep } )
                            classesNowrap = frame.args.classesNowrap,
                            classesPrefix = frame.args.classesPrefix,
                             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.nowrap == "1",
                             frame.args.nowrap == "1",
                            frame.args.id,
                            frame.args.lang,
                             frame.args.sep,
                             frame.args.sep,
                             frame )
                             frame )