Модуль:Universal infocard: юрамалар арасында аерма

Контент бетерелгән Контент өстәлгән
к Ilnur efende үзгәртүләре (бәхәс) Takhirgeran Umar юрамасына кадәр кире кайтарылды
Тамга: кире кайтару
Putnik (бәхәс | кертем)
Copying 2 changes by Putnik: CSS classes instead of styles,support custom CSS class for .infobox from mw:Module:Universal infocard. (docs)
Тамга: кулдан кире кайтару DiBabel [1.2]
 
Юл номеры - 17:
local entityId = nil;
 
-- StylesCSS classes.
local stylesclasses = {};
if config and config.stylesclasses then
infobox = '',
for key, value in pairs( config.stylesclasses ) do
error = '',
stylesclasses[ key ] = value;
title = 'background:#eaecf0; font-weight:bold;',
original = 'font-style:oblique;',
label = 'width:9em;',
text = '',
media = '',
split = 'vertical-align:middle; text-align:center;',
footer = 'background:#eaecf0;',
};
local classes = {
title = 'infobox-above',
media = 'infobox-image',
footer = 'infobox-below'
};
if config and config.styles then
for key, value in pairs( config.styles ) do
styles[ key ] = value;
end
end
function getClassString( type )
local class;
if classes[type] then
class = classes[type];
elseif type ~= '' then
class = 'infobox-' .. type;
else
title class = 'infobox-above',;
end
 
if class == '' then
return '';
end
 
return ' class="'.. class .. '"';
end
 
 
function getTemplate( propertyId )
Строка 94 ⟶ 97 :
colspan = 'colspan="2"';
end
result = result .. '<td ' .. colspan .. 'getClassString( style="'split' .. styles.split) .. '">';
result = result .. value1;
result = result .. '</td>';
Строка 103 ⟶ 106 :
colspan = 'colspan="2"';
end
result = result .. '<td ' .. colspan .. 'getClassString( style="'split' .. styles.split) .. '">';
result = result .. value2;
result = result .. '</td>';
Строка 113 ⟶ 116 :
end
 
function getLine( value, style, class )
local result = '';
if ( value and string.len( value ) ~= 0 ) then
result = result .. '<tr><td colspan="2" style="text-align:center;' .. getClassString( style or '' ) .. '" class="'.. ( class or '' ) .. '">';
result = result .. value;
result = result .. '</td></tr>\n';
Строка 128 ⟶ 131 :
if ( value ~= nil and string.len( value ) ~= 0 ) then
if label then
result = result .. '<tr><th style="' .. styles.getClassString( 'label' ) .. '">' .. label .. '</th>';
result = result .. '<td style="' .. styles.getClassString( 'text' ) .. '">\n';
else
result = result .. '<tr><td colspan="2" style="' .. styles.getClassString( 'text' ) .. '">';
end
result = result .. value;
Строка 155 ⟶ 158 :
local coord = statements[ 1 ].mainsnak.datavalue.value;
local title = expandTemplate( args.frame, getTemplate( 'title' ), { from = entityId } );
 
mw.logObject( coord, 'coord' );
mw.logObject( title, 'title' );
 
 
local mapContent = [[ {
Строка 280 ⟶ 279 :
 
function getErrorMessage( message )
local result = '<table class="infobox" cellspacing="2"' .. getClassString( 'error' ) .. '>\n';
result = result .. '<tr><td colspan="2" style="text-align:center">' .. message .. '</td></tr>\n';
if config and config.styles and config.styles.inferrorobox then
result = result .. ' style="' .. config.styles.error .. '"';
end
result = result .. '>\n';
result = result .. '<tr><td colspan="2" style="text-align:center">' .. message .. '</td></tr>\n';
result = result .. '</table>';
return result;
Строка 302 ⟶ 297 :
end
 
local result = '<table class="infobox" cellspacing="2"' .. getClassString( '' );
if config and config.i18n and config.i18n.dataName then
result = result .. ' data-name="' .. config.i18n.dataName .. '"';
end
if config and config.styles and config.styles.infobox then
result = result .. ' style="' .. config.styles.infobox .. '"';
end
result = result .. '>\n';
Строка 362 ⟶ 354 :
label = expandTemplate( frame, titleTemplate, { from = entityId } );
end
result = result .. getLine( label, styles.title, classes.title'above' );
 
---- Original name.
if claims.P1559 ~= nil then
result = result .. getLine( expandTemplate( frame, getTemplate( 'P1559' ), { from = entityId } ), styles.'original' );
elseif claims.P1705 ~= nil then
result = result .. getLine( expandTemplate( frame, getTemplate( 'P1705' ), { from = entityId } ), styles.'original' );
end
 
Строка 421 ⟶ 413 :
local label = propertyLabel( propertyId );
if propertyClaims[ 1 ].mainsnak.datatype == 'commonsMedia' then
result = result .. getLine( renderValue( frame, propertyId, { alt = label } ), styles.media, classes.media'image' );
else
result = result .. getValue( label, renderValue( frame, propertyId ) );
Строка 434 ⟶ 426 :
---- Map.
if claims.P625 ~= nil then
result = result .. getLine( renderValue( frame, 'map' ), styles.'text' );
end
 
---- Commons.
if claims.P373 ~= nil then
result = result .. getLine( expandTemplate( frame, getTemplate( 'P373' ), { from = entityId } ), styles.footer, classes.footer'below' );
end