Module:Design

local p = {} local h = require("Module:HF") local getArgs = require('Dev:Arguments').getArgs

function p.lua_getMainBorderColor return '#B5B7CF' end

function p.lua_getMainBackgroundColor return '#EFF0FF' end

function p.lua_getStaffFieldName return {'Writer', 'Penciler', 'Inker', 'Colourist', 'Letterer', 'AdaptedFrom', 'Editor', 'CoverArtist', 'Editor-in-Chief', 'CCO', 'President', 'Publisher', 'Production' } end

-- creates message box function p.messagebox(frame) local args = getArgs (frame) local width = args['width'] or '95%' local textalign = args['text-align'] or 'center' local fontsize = args['font-size'] or '100%' local border = args['border'] or p.lua_getMainBorderColor local background = args['background'] or p.lua_getMainBackgroundColor local margin = args['margin'] or '1em' local clear = args['clear'] or 'none' local padding = args['padding'] or '5px' local extrastyle = args['extrastyle'] or '' local message = args[1] or args['Message'] or '' local tag = mw.html.create( 'div' ) :attr( 'id', 'messageBox' ) :attr( 'align', 'center' ) :css( 'width', width ) :css( 'text-align', textalign ) :css( 'font-size', fontsize ) :css( 'border', '1px solid '..border ) :css( 'background', background ) :css( 'border-radius', '10px' ) :css( 'margin', margin ) :css( 'clear', clear ) :css( 'padding', padding ) :wikitext( message ) :done if not h.isempty(extrastyle) then tag:cssText (extrastyle):done end return tostring(tag) end

-- creates a header function p.lua_header(text, level, align) local output = '' level = level or '2' align = align or 'left' if not h.isempty(text) then output = '\n'..tostring( mw.html.create( 'h'..level ):css('text-align', align):wikitext( text ) ) end return output end

function p.show_hide(frame) local args = getArgs (frame)

local title = args['title'] or args['header'] or ' ' local body = args['body'] or args['text'] or '' local collapsed = args['collapsed'] local clear = args['clear'] or 'both' local border = args['border'] or p.lua_getMainBorderColor local extrastyle = args['extrastyle'] or '' local extrastyle2 = args['extrastyle2'] or '' local extrastyle3 = args['extrastyle3'] or '' local width = args['width'] or '100%' local background = args['background'] or p.lua_getMainBackgroundColor local titlestyle = args['titlestyle'] or ''

if h.isempty(collapsed) or collapsed == 'true' or collapsed == true then collapsed = ' mw-collapsed' else collapsed = '' end

local tag_td = mw.html.create( 'td' ) :css( 'margin', '0.5em' ) :css( 'font-size', '1em' ) :wikitext(body) :done if not h.isempty(extrastyle3) then tag_td:cssText (extrastyle3):done end tag_td = ' '..tostring(tag_td)..' '

local tag_div = mw.html.create( 'div' ) :css( 'font-weight', 'bold' ) :wikitext(title) :done if not h.isempty(titlestyle) then tag_div:cssText (titlestyle):done end tag_div = tostring(tag_div) local tag_th = mw.html.create( 'th' ) :attr('colspan', '1') :css( 'background-color', background ) :css( 'font-size', '1.1em' ) :wikitext(tag_div) :done if not h.isempty(extrastyle2) then tag_th:cssText (extrastyle2):done end tag_th = ' '..tostring(tag_th)..' ' local tag_table = mw.html.create( 'table' ) :addClass('mw-collapsible'..collapsed) :css( 'clear', clear ) :css( 'border', '1px solid '..border ) :css( 'font-size', '0.85em' ) :css( 'width', width ) :wikitext(tag_th..tag_td) :done if not h.isempty(extrastyle) then tag_table:cssText (extrastyle):done end return tostring(tag_table) end

function p.story_contributors(frame) local args = getArgs (frame) local pagename = args['pagename'] or '' local storytitle = args['storytitle'] or '' local stories_n = args['stories_n'] or '' local body = args['body'] or '' local output = '' if not h.isempty(body) then output = p.show_hide({           collapsed   = true,            extrastyle  = 'width:100%; margin:0px; border:none; border-top:2px solid '..p.lua_getMainBorderColor..'; text-align:left; font-size: 10px;',            title       = h.Link(pagename..'#Appearing in '..storytitle, stories_n..'. '..storytitle),            body        = body        }) end return output end

function p.infobox_line(frame) local args = getArgs (frame) local left = args['left'] or '' local right = args['right'] or '' local text = args['text'] or '' local width_l = args['width_l'] or '100px' local width_r = args['width_r'] or '190px'

local tag_l = mw.html.create( 'div' ) :css( 'width', width_l ) :css( 'text-align', 'left' ) :css( 'float', 'left' ) :wikitext(left) :done local tag_r = mw.html.create( 'div' ) :css( 'width', width_r ) :css( 'text-align', 'right' ) :css( 'float', 'left' ) :wikitext(right) :done tag_l = tostring(tag_l) tag_r = tostring(tag_r) local tag = mw.html.create( 'div' ) :css( 'border-top', '1px solid '..p.lua_getMainBorderColor ) :css( 'text-align', 'center' ) :css( 'clear', 'left' ) :css( 'font-size', '10px' ) :wikitext(text..tag_l..tag_r) :done return tostring(tag) end

function p.infobox_line_horizontal(frame) local args = getArgs (frame) local leftheader = args['left_header'] local lefttext = args['left_text'] or '' local rightheader = args['right_header'] or '' local righttext = args['right_text'] or '' local totalwidth = args['total_width'] local fontsize_text = args['font_size_text'] or '10px' local output = ''

if not h.isempty(righttext) then if not h.isempty(totalwidth) then totalwidth = tostring(tonumber(totalwidth)/2)..'px' else totalwidth = '50%' end else totalwidth = '100%' end

local tag_leftheader = mw.html.create( 'div' ) :css( 'width', totalwidth ) :css( 'float', 'left' ) :css( 'font-size', '10px' ) :wikitext(leftheader) :done output = output..tostring(tag_leftheader) if not h.isempty(righttext) then local tag_rightheader = mw.html.create( 'div' ) :css( 'width', totalwidth ) :css( 'float', 'left' ) :css( 'clear', 'right' ) :css( 'font-size', '10px' ) :wikitext(rightheader) :done output = output..tostring(tag_rightheader) end --output = output..' ' local tag_lefttext = mw.html.create( 'div' ) :css( 'width', totalwidth ) :css( 'float', 'left' ) :css( 'clear', 'left' ) :css( 'font-size', fontsize_text ) :wikitext(lefttext) :done output = output..tostring(tag_lefttext)

if not h.isempty(righttext) then local tag_righttext = mw.html.create( 'div' ) :css( 'width', totalwidth ) :css( 'float', 'left' ) :css( 'font-size', fontsize_text ) :css( 'text-align', 'center' ) :wikitext(righttext) :done output = output..tostring(tag_righttext) end

return tostring( mw.html.create( 'div' )       :css( 'border-top', '1px solid '..p.lua_getMainBorderColor )        :css( 'text-align', 'center' )        --:css( 'clear', 'left' )        :wikitext(output)        :done ) end

--transform the list of contributors into infobox line with or without categorization function p.infobox_line_staff(frame) local SC = require("Module:StaffCorrection") local staff_fieldname = p.lua_getStaffFieldName local staff_link_name = {'Writers', 'Pencilers', 'Inkers', 'Colourists', 'Letterers', 'Adapted Stories', 'Editors', 'Cover Artists', 'Editors-in-Chief', 'Chief Creative Officers', 'Presidents', 'Publishers', 'Producers'} local staff_link_text = {'Writer', 'Penciler', 'Inker', 'Colourist', 'Letterer', 'Adapted from original material by', 'Editor', 'Cover Artist', 'Editor-in-Chief', 'Chief Creative Officer', 'President', 'Publisher', 'Producer'} local staff_category_name = {'Writer', 'Penciler', 'Inker', 'Colourist', 'Letterer', 'Adapted Stories', 'Editor', 'Cover Artist', 'Editor-in-Chief', 'Chief Creative Officer', 'President', 'Publisher', 'Producer'} local staff_category_needed = {true, true, true, true, true, false, true, true, true, false, false, false, false} local staff_infobox_link = {true, true, true, true, true, true, true, true, true, false, false, false, false} local args = getArgs (frame) local list = args['list'] or {} local n = args['n'] or 1 local categorize = args['categorize'] or true local released = args['released'] or true local canceled = args['canceled'] or false

local i   local name = '' local corrected = '' local job = '' local output = '' local list2 = {} local categories = {}

if not h.isempty(list) then if staff_infobox_link[n] == true then job = ..staff_link_text[n].. else job = staff_link_text[n] end for i = 1, #list do               v = list[i] if not h.isempty(v) then c = SC.Correction(v) if string.lower(v) == 'uncredited' or string.lower(v) == 'n/a' then list2[i] = '\nUncredited' else list2[i] = h.Link(c, v)..' '                               if cat == true then table.insert(categories, c..'/'..staff_category_name[n]) end end end end list2 = table.concat(list2) if not h.isempty(list2) then output = p.infobox_line( { left = job, right = list2 }) end elseif staff_category_needed[n] and released and not canceled then table.insert(categories, staff_category_name[n]..' Needed') end return output, categories end

function p.lua_createInfobox(text) return tostring( mw.html.create( 'div' )       :attr('class', 'infobox')        :css( 'width', '300px' )        :css( 'float', 'right' )        :css( 'clear', 'none' )        :css( 'margin', '0px 0px 1em 1em' )        :css( 'border', '1px solid '..p.lua_getMainBorderColor )        :css( 'background', p.lua_getMainBackgroundColor )        :css( 'border-radius', '10px' )        :css( 'padding', '10px' )        :wikitext(text)        :done ) end

return p