![]() |
VOOZH | about |
This template is borrowed from Wikipedia Template:Calculator ifenabled.
Allows you to detect if the calculator gadget is enabled and provide fallback content for cases where it is not such as when printing. See w:Template:Calculator for details on the simplecalc template system.
{{simplecalc ifenabled|enabled=Lets show a calculator widget {{simplecalc|type=number|size=4}}|disabled=Calculator widgets are not supported}}
Which outputs:
If you add the scoped parameter, then calculators inside the enabled branch do not affect other calculators on the page. There is also a refreshonload parameter to force a refresh on first page load instead of first interaction as usual (this only works if scoped is set). For example:
{{simplecalc ifenabled|scoped=true|enabled=Lets show a calculator widget: {{simplecalc|type=number|id=x|size=2}}. The value of X is: {{simplecalc|type=text|readonly=1|formula=x|default=0|size=2}}.}} The X over here ( {{simplecalc|type=text|readonly=1|formula=x|default=0|size=2}} ) does not get updated, as the previous {{tl|simplecalc ifenabled}} is scoped.
{{}} is scoped.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| enabled | enabled 1 | Text to show if simplecalc is supported
| Content | required |
| scoped | scoped | Mark the calculators inside the enabled branch as isolated from the rest of the page | Boolean | optional |
| class | class | Extra css classes for the enabled branch | String | optional |
| refreshonload | refreshonload | Refresh the calculators on the initial page load before any user interaction (required scoped to be set) | Boolean | optional |
| disabled | disabled 2 | Text to show if simplecalc is not enabled (for example during print)
| Content | suggested |
| class disabled | class disabled | Extra css classes for the disabled branch | String | optional |