maintenance: Add maintenance script for managing foreign resources
[lhc/web/wiklou.git] / resources / src / jquery / jquery.makeCollapsible.styles.less
1 /**
2 * These rules prevent re-flows relating to collapsible on-wiki elements (T42812).
3 * This is done by temporarily creating a pseudo element in the place that JavaScript will insert
4 * a toggle control. The same CSS rules that control the positioning of the toggle control will apply
5 * to the pseudo element. When the JavaScript has executed
6 * (See corresponding non-render blocking CSS in jquery.makeCollapsible)
7 * all pseudo elements will be removed.
8 *
9 * Currently we support all the examples on [[mw:Manual:Collapsible_elements/Demo/Simple]]
10 * All examples on [[mw:Manual:Collapsible_elements/Demo/Advanced]] are supported with the following
11 * exceptions
12 * - Custom collapsible 4 (table-row)
13 * -- CSS selector would be too complicated
14 * - Collapsible div nested in collapsed div
15 * -- Given it's not easy to identify the collapsed content via CSS, text will be shown until
16 * JavaScript has loaded
17 * - "Combination example"
18 * -- At a later time, we may want to support the use of of `attr`, but given the code
19 * complexity we will not for the time being (see https://davidwalsh.name/css-content-attr)
20 */
21
22 // This selector is used frequently in the code to indicate that the JavaScript has successfully completed
23 // it's execution and pseudo elements can be disabled. For readability and maintainability it is separated
24 // as a LESS variable.
25 @exclude: ~'.mw-made-collapsible';
26
27 .client-js {
28
29 ol.mw-collapsible:before,
30 ul.mw-collapsible:before,
31 .mw-collapsible-toggle-li {
32 /*
33 Rather than inherit any margins from the general li selector - make sure this is explicit
34 to avoid reflows
35 */
36 display: list-item;
37 list-style: none;
38 margin-bottom: 0.1em;
39 }
40
41 // Reset when mw-collapsible-toggle-li is rendered
42 ol.mw-made-collapsible:before,
43 ul.mw-made-collapsible:before {
44 display: none;
45 }
46
47 ol.mw-collapsible:not( @{exclude} ):before,
48 ul.mw-collapsible:not( @{exclude} ):before,
49 // Where the tbody or thead is the first child of the collapsible table
50 table.mw-collapsible:not( @{exclude} ) :first-child tr:first-child th:last-child:before,
51 table.mw-collapsible:not( @{exclude} ) > caption:first-child:after {
52 content: '[@{msg-collapsible-collapse}]';
53 }
54
55 td.mw-collapsed:not( @{exclude} ):before,
56 table.mw-collapsed:not( @{exclude} ) :first-child tr:first-child th:last-child:before,
57 table.mw-collapsed:not( @{exclude} ) > caption:first-child:after,
58 div.mw-collapsed:not( @{exclude} ):before {
59 content: '[@{msg-collapsible-expand}]';
60 }
61
62 // Any element with id beginning `mw-customcollapsible` will have special treatment
63 .mw-collapsible[ id^='mw-customcollapsible' ] th:before,
64 .mw-collapsible[ id^='mw-customcollapsible' ]:before {
65 content: none !important; // stylelint-disable-line declaration-no-important
66 }
67
68 // Special case for table where first child is caption element
69 table.mw-collapsible:not( @{exclude} ) > caption:first-child:after {
70 float: none;
71 display: block;
72 }
73
74 // Use the exclude selector to ensure animations do not break
75 .mw-collapsed:not( @{exclude} ) {
76 // Avoid FOUC/reflows on collapsed elements by making sure they are opened by default (T42812)
77 > p,
78 > table,
79 // Manual:Collapsible_elements/Demo/Simple#Collapsed_by_default
80 > thead + tbody,
81 tr:not( :first-child ),
82 .mw-collapsible-content {
83 display: none;
84 }
85 }
86 }
87
88 /* Align the toggle based on the direction of the content language */
89 /* @noflip */
90 .mw-content-ltr,
91 .mw-content-rtl .mw-content-ltr {
92 .mw-collapsible:not( @{exclude} ) th:before,
93 .mw-collapsible:not( @{exclude} ):before,
94 .mw-collapsible-toggle {
95 float: right;
96 }
97 }
98
99 /* @noflip */
100 .mw-content-rtl,
101 .mw-content-ltr .mw-content-rtl {
102 .mw-collapsible:not( @{exclude} ) th:before,
103 .mw-collapsible:not( @{exclude} ):before,
104 .mw-collapsible-toggle {
105 float: left;
106 }
107 }
108
109 /* list-items go as wide as their parent element, don't float them inside list items */
110 li,
111 .mw-content-ltr li,
112 .mw-content-rtl li,
113 .mw-content-ltr .mw-content-rtl li,
114 .mw-content-rtl .mw-content-ltr li {
115 .mw-collapsible-toggle {
116 float: none;
117 }
118 }
119
120 // special treatment for list items to match above
121 // !important necessary to override overly-specific float left and right above.
122 ol.mw-collapsible:not( @{exclude} ):before,
123 ul.mw-collapsible:not( @{exclude} ):before {
124 float: none !important; // stylelint-disable-line declaration-no-important
125 }