r59990 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59989‎ | r59990 | r59991 >
Date:00:51, 12 December 2009
Author:yaron
Status:deferred (Comments)
Tags:
Comment:
Fixes to make CSS simpler, more generic, more readable and work in right-to-left languages
Modified paths:
  • /trunk/extensions/TemplateInfo/TemplateInfo.classes.php (modified) (history)
  • /trunk/extensions/TemplateInfo/TemplateInfo.css (modified) (history)

Diff [purge]

Index: trunk/extensions/TemplateInfo/TemplateInfo.classes.php
@@ -52,16 +52,16 @@
5353 } else {
5454 $content = "$data_type: " . HTML::element('span', array('class' => 'rowValue'), $value);
5555 }
56 - $cell = HTML::rawElement('td', array('colspan' => 2), $content);
57 - $text = HTML::rawElement('tr', array('class' => $css_class), $cell);
 56+ $cell = HTML::rawElement('td', array('colspan' => 2, 'class' => $css_class), $content);
 57+ $text = HTML::rawElement('tr', null, $cell);
5858 $text .= "\n";
5959 return $text;
6060 }
6161
6262 static function tableMessageRowHTML($css_class, $name, $value) {
63 - $cell1 = HTML::element('td', array(), $name);
 63+ $cell1 = HTML::element('td', array('class' => $css_class), $name);
6464 $cell2 = HTML::element('td', array('class' => 'msg'), $value);
65 - $text = HTML::rawElement('tr', array('class' => $css_class), $cell1 . "\n" . $cell2);
 65+ $text = HTML::rawElement('tr', null, $cell1 . "\n" . $cell2);
6666 $text .= "\n";
6767 return $text;
6868 }
@@ -82,7 +82,7 @@
8383
8484 static function parseParamGroup($param_group_xml) {
8585 $id = $param_group_xml->attributes()->id;
86 - $text = self::tableRowHTML('topRow', 'Group', $id);
 86+ $text = self::tableRowHTML('paramGroup', 'Group', $id);
8787 foreach ($param_group_xml->children() as $child) {
8888 $text .= self::parseParam($child);
8989 }
@@ -91,7 +91,7 @@
9292
9393 static function parseParam($param_xml) {
9494 $id = $param_xml->attributes()->id;
95 - $text = self::tableRowHTML('row2', 'Parameter', $id);
 95+ $text = self::tableRowHTML('param', 'Parameter', $id);
9696 foreach ($param_xml->children() as $tag_name => $child) {
9797 if ($tag_name == 'label') {
9898 $text .= self::parseParamLabel($child);
@@ -110,9 +110,9 @@
111111
112112 static function parseParamLabel($param_label_xml) {
113113 if (count($param_label_xml->children()) == 0) {
114 - $text = self::tableRowHTML('row3', 'Label', $param_label_xml);
 114+ $text = self::tableRowHTML('paramAttr', 'Label', $param_label_xml);
115115 } else {
116 - $text = self::tableRowHTML('row3', 'Label');
 116+ $text = self::tableRowHTML('paramAttr', 'Label');
117117 foreach ($param_label_xml->children() as $child) {
118118 $text .= self::parseMsg($child);
119119 }
@@ -122,9 +122,9 @@
123123
124124 static function parseParamDescription($param_desc_xml) {
125125 if (count($param_desc_xml->children()) == 0) {
126 - $text = self::tableRowHTML('row3', 'Description', $param_desc_xml);
 126+ $text = self::tableRowHTML('paramAttr', 'Description', $param_desc_xml);
127127 } else {
128 - $text = self::tableRowHTML('row3', 'Description');
 128+ $text = self::tableRowHTML('paramAttr', 'Description');
129129 foreach ($param_desc_xml->children() as $child) {
130130 $text .= self::parseMsg($child);
131131 }
@@ -134,12 +134,12 @@
135135
136136 static function parseParamType($param_type_xml) {
137137 $name = $param_type_xml->attributes()->name;
138 - $text = self::tableRowHTML('row3', 'Type', $name);
 138+ $text = self::tableRowHTML('paramAttr', 'Type', $name);
139139 return $text;
140140 }
141141
142142 static function parseParamOptions($param_options_xml) {
143 - $text = self::tableRowHTML('optionsTopRow', 'Options');
 143+ $text = self::tableRowHTML('paramOptions', 'Options');
144144 foreach ($param_options_xml->children() as $child) {
145145 $text .= self::parseParamOption($child);
146146 }
@@ -148,9 +148,9 @@
149149
150150 static function parseParamOption($param_option_xml) {
151151 $name = $param_option_xml->attributes()->name;
152 - $text = self::tableRowHTML('optionsRow2', 'Option', $name);
 152+ $text = self::tableRowHTML('paramOption', 'Option', $name);
153153 if (count($param_option_xml->children()) == 0) {
154 - $text .= self::tableRowHTML('optionsRow3', $param_option_xml);
 154+ $text .= self::tableRowHTML('paramOptionMsg', $param_option_xml);
155155 } else {
156156 foreach ($param_option_xml->children() as $child) {
157157 $text .= self::parseOptionMsg($child);
@@ -161,19 +161,19 @@
162162
163163 static function parseMsg($msg_xml) {
164164 $language = $msg_xml->attributes()->language;
165 - $text = self::tableMessageRowHTML('row4', $language, $msg_xml);
 165+ $text = self::tableMessageRowHTML('paramAttrMsg', $language, $msg_xml);
166166 return $text;
167167 }
168168
169169 static function parseOptionMsg($msg_xml) {
170170 $language = $msg_xml->attributes()->language;
171 - $text = self::tableMessageRowHTML('optionsRow3', $language, $msg_xml);
 171+ $text = self::tableMessageRowHTML('paramOptionMsg', $language, $msg_xml);
172172 return $text;
173173 }
174174
175175 static function parseParamData($param_data_xml) {
176176 $app = $param_data_xml->attributes()->app;
177 - $text = self::tableRowHTML('dataTopRow', 'Data for app', $app);
 177+ $text = self::tableRowHTML('paramData', 'Data for app', $app);
178178 foreach ($param_data_xml->children() as $child) {
179179 $text .= self::parseField($child);
180180 }
@@ -182,7 +182,7 @@
183183
184184 static function parseField($field_xml) {
185185 $name = $field_xml->attributes()->name;
186 - $text = self::tableMessageRowHTML('dataRow2', $name, $field_xml);
 186+ $text = self::tableMessageRowHTML('paramDataField', $name, $field_xml);
187187 return $text;
188188 }
189189
Index: trunk/extensions/TemplateInfo/TemplateInfo.css
@@ -1,84 +1,113 @@
2 -table.templateInfo td {
 2+.templateInfo td {
33 padding-right: 5px;
44 }
55
6 -table.templateInfo tr.topRow {
7 - background: #bbaa88;
 6+body.rtl .templateInfo td {
 7+ padding-left: 5px;
88 }
99
10 -table.templateInfo tr.topRow td {
 10+.templateInfo .paramGroup {
 11+ background: #bbaa88;
1112 padding-left: 5px;
1213 }
1314
14 -table.templateInfo tr.topRow span.rowValue {
 15+body.rtl .templateInfo .paramGroup {
 16+ padding-right: 5px;
 17+}
 18+
 19+.templateInfo .paramGroup span.rowValue {
1520 font-weight: bold;
1621 }
1722
18 -table.templateInfo tr.row2 {
 23+.templateInfo .param {
1924 background: #d3c2a0;
 25+ padding-left: 20px;
2026 }
2127
22 -table.templateInfo tr.row2 td {
23 - padding-left: 20px;
 28+body.rtl .templateInfo .param {
 29+ padding-right: 20px;
2430 }
2531
26 -table.templateInfo tr.row2 span.rowValue {
 32+.templateInfo .param span.rowValue {
2733 font-weight: bold;
2834 }
2935
30 -table.templateInfo tr.row3 {
 36+.templateInfo .paramAttr {
3137 background: #eeddbb;
 38+ padding-left: 35px;
3239 }
3340
34 -table.templateInfo tr.row3 td {
35 - padding-left: 35px;
 41+body.rtl .templateInfo .paramAttr {
 42+ padding-right: 35px;
3643 }
3744
38 -table.templateInfo tr.row4 {
 45+.templateInfo .paramAttrMsg {
3946 background: #ffeecc;
 47+ padding-left: 50px;
4048 }
4149
42 -table.templateInfo tr.row4 td {
43 - padding-left: 50px;
 50+body.rtl .templateInfo .paramAttrMsg {
 51+ padding-right: 50px;
4452 }
4553
46 -table.templateInfo tr.optionsTopRow td {
 54+.templateInfo .paramOptions {
4755 padding-left: 20px;
4856 background: #ffff77;
4957 }
5058
51 -table.templateInfo tr.optionsRow2 td {
 59+body.rtl .templateInfo .paramOptions {
 60+ padding-right: 20px;
 61+}
 62+
 63+.templateInfo .paramOption {
5264 padding-left: 35px;
5365 background: #ffff99;
5466 }
5567
56 -table.templateInfo tr.optionsRow2 span.rowValue {
 68+body.rtl .templateInfo .paramOption {
 69+ padding-right: 35px;
 70+}
 71+
 72+.templateInfo .paramOption span.rowValue {
5773 font-weight: bold;
5874 }
5975
60 -table.templateInfo tr.optionsRow3 td {
 76+.templateInfo .paramOptionMsg {
6177 padding-left: 50px;
6278 background: #ffffbb;
6379 }
6480
65 -table.templateInfo tr.dataTopRow td {
 81+body.rtl .templateInfo .paramOptionMsg {
 82+ padding-right: 50px;
 83+}
 84+
 85+.templateInfo .paramData {
6686 padding-left: 20px;
6787 background: #77dd77;
6888 }
6989
70 -table.templateInfo tr.dataTopRow span.rowValue {
 90+body.rtl .templateInfo .paramData {
 91+ padding-right: 20px;
 92+}
 93+
 94+.templateInfo .paramData span.rowValue {
7195 font-weight: bold;
7296 }
7397
74 -table.templateInfo tr.dataRow2 {
 98+.templateInfo .paramDataField {
7599 background: #99ff99;
 100+ padding-left: 35px;
76101 }
77102
78 -table.templateInfo tr.dataRow2 td {
79 - padding-left: 35px;
 103+body.rtl .templateInfo .paramDataField {
 104+ padding-right: 35px;
80105 }
81106
82 -table.templateInfo tr td.msg {
 107+.templateInfo .msg {
83108 padding-left: 5px;
84109 background: white;
85110 }
 111+
 112+body.rtl .templateInfo .msg {
 113+ padding-right: 5px;
 114+}

Comments

#Comment by Catrope (talk | contribs)   00:59, 12 December 2009
+.templateInfo .msg {
 	padding-left: 5px;
 	background: white;
 }
+
+body.rtl .templateInfo .msg {
+	padding-right: 5px;
+}

If I'm reading this correctly, body.rtl .templateInfo .msg will get 5px of padding on both sides. Doesn't this need an additional padding-left: 0; rule to counter that? I'm not sure about this, so I'll ask Trevor to confirm.

#Comment by Trevor Parscal (WMF) (talk | contribs)   01:08, 12 December 2009

Yes, the RTL version should negate the LTR version. When doing margins and padding, you can do "padding-left: 0;" as Roan mentions. Some things like absolute positioning need the keyword "auto" for left and right.

Status & tagging log