Basculer le menu
Changer de menu des préférences
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

« Module:Infobox/Core » : différence entre les versions

De Nefald
Hiob (discussion | contributions)
m +namespace 3000
Hiob (discussion | contributions)
Port depuis codex.nefald.fr : masquage des sections vides, champs sans label pleine largeur, icône configurable par fonction (via update-page on MediaWiki MCP Server)
 
Ligne 152 : Ligne 152 :


     for _, section in ipairs(config.sections or {}) do
     for _, section in ipairs(config.sections or {}) do
         if section.titre then
         -- Les lignes de la section sont accumulées ici et intégrées au body seulement
            local sectionDiv = mw.html.create('div')
        -- si au moins une a du contenu — sinon le section-title reste orphelin (ex. une
                :addClass('infobox-section-title')
        -- section "Sous-pages" ou "Compatibilité" entièrement vide sur cette page).
                :wikitext(section.titre)
         local sectionRows = {}
            body:node(sectionDiv)
         end


         for _, champ in ipairs(section.champs or {}) do
         for _, champ in ipairs(section.champs or {}) do
Ligne 174 : Ligne 172 :
                  
                  
                 rowDiv:node(labelDiv):node(valueDiv)
                 rowDiv:node(labelDiv):node(valueDiv)
                 body:node(rowDiv)
                 table.insert(sectionRows, rowDiv)
                 coordinatesDisplayed = true
                 coordinatesDisplayed = true
                  
                  
Ligne 195 : Ligne 193 :
                             :addClass('infobox-row')
                             :addClass('infobox-row')


                        local labelDiv = mw.html.create('div')
                            :addClass('infobox-label')
                            :wikitext(champ.label)
                       
                         local valueDiv = mw.html.create('div')
                         local valueDiv = mw.html.create('div')
                             :addClass('infobox-value')
                             :addClass('infobox-value')
                        -- Champ sans label (ex. liste pleine largeur type Sous-pages) :
                        -- pas de colonne label, la valeur devient seule enfant flex du
                        -- row et occupe donc naturellement 100% de la largeur.
                        if champ.label and champ.label ~= '' then
                            local labelDiv = mw.html.create('div')
                                :addClass('infobox-label')
                                :wikitext(champ.label)
                            rowDiv:node(labelDiv)
                        end
                          
                          
                         -- Formatage spécial pour le champ "type"
                         -- Formatage spécial pour le champ "type"
Ligne 209 : Ligne 213 :
                         end
                         end


                         rowDiv:node(labelDiv):node(valueDiv)
                         rowDiv:node(valueDiv)
                         body:node(rowDiv)
                         table.insert(sectionRows, rowDiv)
                     end
                     end
                 end
                 end
            end
        end
        if #sectionRows > 0 then
            if section.titre then
                local sectionDiv = mw.html.create('div')
                    :addClass('infobox-section-title')
                    :wikitext(section.titre)
                body:node(sectionDiv)
            end
            for _, rowDiv in ipairs(sectionRows) do
                body:node(rowDiv)
             end
             end
         end
         end
Ligne 223 : Ligne 239 :
      
      
     if config.icone then
     if config.icone then
         local iconeType = config.icone.type or 'fas'
         local iconeConfig = config.icone
         local iconeNom = config.icone.nom
        if type(iconeConfig) == 'function' then
            iconeConfig = iconeConfig(args) or {}
        end
        local iconeType = iconeConfig.type or 'fas'
         local iconeNom = iconeConfig.nom
          
          
         -- Utiliser mw.getCurrentFrame() si frame n'est pas disponible
         -- Utiliser mw.getCurrentFrame() si frame n'est pas disponible
Les témoins (''cookies'') nous aident à fournir nos services. En utilisant nos services, vous acceptez notre utilisation de témoins.