Template:Su: Difference between revisions

From Vigyanwiki
Template>Edokter
(Fix too small monospace fontsize)
Template>Wikid77
(put noincluded values to show live position & size; reduced #if to 1-level depth; larger {fontsize|85%}; raised "line-height:1.2em" for IE6 subscript "g"; allow align=right/center; updated NOTES text)
Line 1: Line 1:
{{#if:{{{p|}}}
<span style="{{#ifeq:{{{w|}}}|f|font-family:monospace,'Courier New';}}font-size:{{{fontsize|85%}}};display:inline-block; vertical-align:-0.4em; line-height:1.2em; margin-bottom:-0.3em; {{#switch:{{{a|{{{align|}}}}}}
  |{{#if:{{{b|}}}
  | r|right = text-align:right;
    |<span style="{{#ifeq:{{{w|}}}|f|font-family:monospace,'Courier New';}}font-size:{{{fontsize|80%}}};overflow:visible;display:inline-block; vertical-align:-0.4em; line-height:1.1em; margin-bottom:-0.2em;background:transparent;text-align:{{#switch:{{{a|}}}|r=right|c=center|left}}">{{{p|{{{p}}}}}}<br />{{{b|{{{b}}}}}}</span>
  | c|center = text-align:center;
    |<sup>{{{p|}}}</sup>
}}">{{{p|<noinclude>{&#123;{p&#124;gH}&#125;}</noinclude>}}}{{
  }}
#if:{{{b|<noinclude>x</noinclude>}}}|<br />{{{b|<noinclude>{&#123;{b&#124;gH}&#125;}</noinclude>}}}}}</span><noinclude><!--
  |<sub>{{{b|}}}</sub>
}}<noinclude><!--endif {p} passed
--------------------------------------------------------------
--------------------------------------------------------------
--NOTES:
--NOTES:
Line 15: Line 13:
--      Usage: {{su | p=super | b=sub}}
--      Usage: {{su | p=super | b=sub}}
--
--
-- NOTE C2: For compatibility with browser MS IE6, the result
-- NOTE C2: For use with browser MS IE6, the result with both
--      with both subscripts is a span with vertical "<br />"
--      superscript & subscript is a span with vertical "<br/>"
--      to align the superscript & subscript together.
--      to align the superscript & subscript together.
--
--
-- NOTE F3: The font can be changed by w=f to select the
-- NOTE F3: The font can be changed by w=f to select the
--      font-family:monospace, or by fontsize=nn% (default:
--      font-family:monospace, or by fontsize=nn% (default:
--      80%) where 100% is the usual super/subscript size.
--      85%) where 100% is the usual font size.
--
--
-- NOTE IE: Because IE6 often handles only 1 style="..." and
-- NOTE IE: Because IE6 often handles only 1 style="..." and
Line 27: Line 25:
--      are combined as 1 <span> when {p}/{b} are both shown.
--      are combined as 1 <span> when {p}/{b} are both shown.
--
--
-- NOTE L5: The logic to select the typesetting, is shown by
-- NOTE N5: The nesting depth of this template was reduced to
--      the following 2 nested if-then-else statements:
--      just 2 levels (from 4) to avoid the MediaWiki 1.16
--
--     "expansion depth limit" inside large templates. The
--       IF superscript {p} exists
--     #switch or #if logic is only 1-level deep.
--        THEN IF subscript {b} exists
--          THEN show both aligned {p}<br>{b}
--          ELSE show superscript {p|} ENDIF
--         ELSE show subscript {b|} ENDIF
--
--
--------------------------------------------------------------
--------------------------------------------------------------
Line 47: Line 41:
--21Dec10 Used 1 <span> when both {p}/{b} for IE6 text-align.
--21Dec10 Used 1 <span> when both {p}/{b} for IE6 text-align.
--21Dec10 Lowered {p} "line-height:1.1em" for Konqueror 3.5.8.
--21Dec10 Lowered {p} "line-height:1.1em" for Konqueror 3.5.8.
--21Dec10 To avoid extra HTML, cut duplicate "line-height:1".
--22Dec10 Put same span-style/size for single super/subscript.
--22Dec10 Unnested logic as just:  #if|{b|} then show <br>{b}.
--22Dec10 Raised "line-height:1.2em" to fit IE6 subscript "g".
--22Dec10 Raised default font-size:85% to fit more browsers.
--22Dec10 Omit "text-align:" unless set a=r or a=c (center).
--22Dec10 Set margin-bottom for browsers w/o vertical-align.
--22Dec10 New parameter align=right (center) same as a=r/a=c.
--22Dec10 Cut unneeded HTML "overflow:visible; background...".
--
--
-->{{documentation}}<!--
-->{{documentation}}<!--
-- PLEASE ADD CATEGORIES & INTERWIKIS TO /doc SUBPAGE - NOT HERE.
-- PLEASE ADD CATEGORIES & INTERWIKIS TO /doc SUBPAGE - NOT HERE.
--></noinclude>
--></noinclude>

Revision as of 11:20, 22 December 2010

{{{p|gH}}}
{{{b|gH}}}

Template documentation