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:Sandbox/Chlod/OOUI button
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!
-- Used to implement {{OOUI button}} -- This is not the same as {{Clickable button 2}}, which uses mw-ui. local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno') local p = {} local finalCategories = {} function p.main(frame) local args = getArgs(frame, { trim = true, removeBlanks = false }) return p._main(frame, args) end function p._main(frame, args) -- aliases args["label"] = args["1"] or args["label"] return tostring(renderButtonWidget(args)) end function renderButtonWidget(args) local wrapper = mw.html.create("span") :addClass("oo-ui-widget") :addClass("oo-ui-buttonElement") :addClass("oo-ui-buttonWidget") -- <icon/label/indicator>Element if args["icon"] and string.len(args["icon"]) > 0 then wrapper:addClass("oo-ui-iconElement") end if args["label"] and string.len(args["label"]) > 0 then wrapper:addClass("oo-ui-labelElement") end if args["indicator"] and string.len(args["indicator"]) > 0 then wrapper:addClass("oo-ui-indicatorElement") end -- flags if args["flags"] == "progressive" or yesno(args["progressive"]) then wrapper:addClass("oo-ui-flaggedElement-progressive") end if args["flags"] == "destructive" or yesno(args["destructive"]) then wrapper:addClass("oo-ui-flaggedElement-destructive") end -- frame if yesno(args["framed"] or "yes") then wrapper:addClass("oo-ui-buttonElement-framed") else wrapper:addClass("oo-ui-buttonElement-frameless") end -- disabled if yesno(args["disabled"] or "no") then wrapper:addClass("oo-ui-widget-disabled") wrapper:attr("aria-diasbled", "true") else wrapper:addClass("oo-ui-widget-enabled") wrapper:attr("aria-diasbled", "false") end wrapper:node(renderButton(args)) return wrapper end function renderButton(args) return mw.html.create("span") :addClass("oo-ui-buttonElement-button") :attr("role", "button") :attr("title", args["title"] or args["label"]) :attr("aria-disabled", yesno(args["disabled"] or "no") and "true" or "false") :node(renderIcon(args["icon"])) :node(renderLabel(args["label"])) :node(renderIndicator(args["indicator"])) end function renderIcon(icon) return mw.html.create("span") :addClass("oo-ui-iconElement-icon") :addClass((icon and string.len(icon) > 0) and ("oo-ui-icon-" .. icon) or "oo-ui-iconElement-noIcon") end function renderLabel(label) return mw.html.create("span") :addClass("oo-ui-labelElement-label") :wikitext(label) end function renderIndicator(indicator) if indicator ~= "clear" and indicator ~= "down" and indicator ~= "required" and indicator ~= "up" and indicator ~= "" and indicator ~= nil then mw.addWarning("Unrecognized indicator: ''" .. indicator .. "''") indicator = "" end return mw.html.create("span") :addClass("oo-ui-indicatorElement-indicator") :addClass((indicator and string.len(indicator) > 0) and ("oo-ui-indicator-" .. indicator) or "oo-ui-indicatorElement-noIndicator") end return p
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:Sandbox/Chlod/OOUI button/doc
(
edit
)