Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:WikiProjectBanner/Row
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
------------------------------------------------------------------------------- -- Row class for Module:WikiProjectBanner -- -- -- -- This class is a parent class for all WikiProject banner rows, e.g. -- -- quality ratings, importance ratings, task forces, notices and requests. -- ------------------------------------------------------------------------------- -- Load required modules. local libraryUtil = require('libraryUtil') local checkType = libraryUtil.checkType -- Lazily load modules we might not need. local mShared local Row = {} Row.__index = Row function Row.new(args, bannerData, cfg, rowCfg) -- Validate the input. checkType('Row.new', 1, args, 'table') checkType('Row.new', 2, bannerData, 'table') checkType('Row.new', 3, cfg, 'table') checkType('Row.new', 4, rowCfg, 'table', true) -- Create the object. local obj = {} setmetatable(obj, Row) -- Set the data we were passed. obj.args = args obj.bannerData = bannerData obj.cfg = cfg obj.rowCfg = rowCfg or {} -- Define the object structure. obj.categories = {} return obj end function Row:isActive() -- To be used only by hooks. mShared = mShared or require('Module:WikiProjectBanner/shared') return mShared.isActiveRow( self.args, self.bannerData, self.cfg, self.rowCfg ) end function Row:_setField(field, val, options) options = options or {} local valType = type(val) if valType == 'function' then val = val{ args = self.args, bannerData = self.bannerData, cfg = self.cfg, rowCfg = self.rowCfg } valType = type(val) end if valType == 'string' then self[field] = val elseif val ~= nil then error(string.format( 'the %s value must be a string (received %s)', field, valType ), 3) end self[field .. 'Style'] = options.style self[field .. 'Class'] = options.class end function Row:setIcon(...) self:_setField('icon', ...) end function Row:setText(...) self:_setField('text', ...) end function Row:addCategory(cat) table.insert(self.categories, cat) end function Row:exportHtml() local row = mw.html.create('tr') row :tag('td') :addClass(self.iconClass) :css(self.iconStyle or {}) :wikitext(self.icon) :done() :tag('td') :addClass('mbox-text') :addClass(self.textClass) :attr('colspan', '2') :css(self.textStyle or {}) :wikitext(self.text) return row end function Row:exportCategories() return self.categories end return Row
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:WikiProjectBanner/Row/doc
(
edit
)