MDL-43902 output: Final deprecation of classes r0/r1 in table rows

This commit is contained in:
Frederic Massart 2014-12-09 10:52:30 +08:00
parent d87bcfb325
commit ba55be9151
9 changed files with 19 additions and 31 deletions

View File

@ -16,9 +16,6 @@
.path-admin-tool-profiling .flexible .referencerun {
font-weight: bold;
}
.path-admin-tool-profiling .flexible .r1 .cell {
background-color: whitesmoke;
}
.path-admin-tool-profiling .flexible {
margin-left:auto;
margin-right:auto

View File

@ -48,11 +48,11 @@ Feature: Site settings can be used to hide parts of the gradebook UI
@javascript
Scenario: Disable category overriding
And ".r1 .course input[type='text']" "css_element" should exist
And "tr .course input[type='text']" "css_element" should exist
Then I navigate to "Grade category settings" node in "Site administration > Grades"
And I click on "Allow category grades to be manually overridden" "checkbox"
And I press "Save changes"
And I follow "Home"
And I follow "Course 1"
And I follow "Grades"
And ".r0 .course input[type='text']" "css_element" should not exist
And "tr .course input[type='text']" "css_element" should not exist

View File

@ -1447,9 +1447,6 @@ class html_writer {
* method. In most cases this is not an issue at all so we do not clone by default for performance
* and memory consumption reasons.
*
* Please do not use .r0/.r1 for css, as they will be removed in Moodle 2.9.
* @todo MDL-43902 , remove r0 and r1 from tr classes.
*
* @param html_table $table data to be rendered
* @return string HTML code
*/
@ -1579,7 +1576,6 @@ class html_writer {
}
if (!empty($table->data)) {
$oddeven = 1;
$keys = array_keys($table->data);
$lastrowkey = end($keys);
$output .= html_writer::start_tag('tbody', array());
@ -1601,12 +1597,10 @@ class html_writer {
$row = $newrow;
}
$oddeven = $oddeven ? 0 : 1;
if (isset($table->rowclasses[$key])) {
$row->attributes['class'] .= ' ' . $table->rowclasses[$key];
}
$row->attributes['class'] .= ' r' . $oddeven;
if ($key == $lastrowkey) {
$row->attributes['class'] .= ' lastrow';
}
@ -2077,9 +2071,7 @@ class html_table {
/**
* @var array Array of classes to add to particular rows, space-separated string.
* Classes 'r0' or 'r1' are added automatically for every odd or even row,
* respectively. Class 'lastrow' is added automatically for the last row
* in the table.
* Class 'lastrow' is added automatically for the last row in the table.
*
* Example of usage:
* $t->rowclasses[9] = 'tenth'

View File

@ -1016,9 +1016,6 @@ class flexible_table {
/**
* This function is not part of the public api.
*
* Please do not use .r0/.r1 for css, as they will be removed in Moodle 2.9.
* @todo MDL-43902 , remove r0 and r1 from tr classes.
*/
function print_row($row, $classname = '') {
echo $this->get_row_html($row, $classname);
@ -1034,8 +1031,7 @@ class flexible_table {
*/
public function get_row_html($row, $classname = '') {
static $suppress_lastrow = NULL;
$oddeven = $this->currentrow % 2;
$rowclasses = array('r' . $oddeven);
$rowclasses = array();
if ($classname) {
$rowclasses[] = $classname;

View File

@ -206,7 +206,7 @@ class core_html_writer_testcase extends basic_testcase {
$expected = <<<EOF
<table class="generaltable" id="Jeffrey" data-name="Colin">
<tbody><tr class="r0 lastrow" id="Bob" data-name="Fred">
<tbody><tr class="lastrow" id="Bob" data-name="Fred">
<td class="cell c0 lastcol" id="Jeremy" data-name="John" style=""></td>
</tr>
</tbody>

View File

@ -361,7 +361,10 @@ class core_tablelib_testcase extends basic_testcase {
$table->define_columns($columns);
$table->define_headers($headers);
$table->define_baseurl('/invalid.php');
$row = $table->get_row_html($data);
$this->assertRegExp('/row 0 col 0/', $row);
$this->assertRegExp('/<tr class=""/', $row);
$this->assertRegExp('/<td class="cell c0"/', $row);
}
}

View File

@ -6,12 +6,12 @@
margin: 0px auto;
}
.path-mod-workshop .manual-allocator .allocations .r0 {
.path-mod-workshop .manual-allocator .allocations tbody tr:nth-of-type(odd) {
background-color: #eee;
}
.path-mod-workshop .manual-allocator .allocations .r0.highlightreviewerof,
.path-mod-workshop .manual-allocator .allocations .r0.highlightreviewedby {
.path-mod-workshop .manual-allocator .allocations tbody tr:nth-of-type(odd).highlightreviewerof,
.path-mod-workshop .manual-allocator .allocations tbody tr:nth-of-type(odd).highlightreviewedby {
background-color: inherit;
}

View File

@ -49,8 +49,8 @@ Feature: View an outline report
And I log in as "teacher1"
And I follow "Course 1"
When I navigate to "Activity report" node in "Course administration > Reports"
Then I should see "2" in the "//tr[contains(concat(' ', normalize-space(@class),' '),' r0 ')]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
And I should see "1" in the "//tr[contains(concat(' ', normalize-space(@class),' '),' r1 ')]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
Then I should see "2" in the "//tbody/tr[(position() mod 2)=1]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
And I should see "1" in the "//tbody/tr[(position() mod 2)=0]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
@javascript
Scenario: View the outline report when only the standard log reader is enabled
@ -71,8 +71,8 @@ Feature: View an outline report
And I log in as "admin"
And I follow "Course 1"
When I navigate to "Activity report" node in "Course administration > Reports"
Then I should see "2" in the "//tr[contains(concat(' ', normalize-space(@class),' '),' r0 ')]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
And I should see "1" in the "//tr[contains(concat(' ', normalize-space(@class),' '),' r1 ')]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
Then I should see "2" in the "//tbody/tr[(position() mod 2)=1]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
And I should see "1" in the "//tbody/tr[(position() mod 2)=0]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
@javascript
Scenario: View the outline report when both the standard and legacy log readers are enabled
@ -95,8 +95,8 @@ Feature: View an outline report
And I log in as "teacher1"
And I follow "Course 1"
When I navigate to "Activity report" node in "Course administration > Reports"
Then I should see "2" in the "//tr[contains(concat(' ', normalize-space(@class),' '),' r0 ')]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
And I should see "1" in the "//tr[contains(concat(' ', normalize-space(@class),' '),' r1 ')]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
Then I should see "2" in the "//tbody/tr[(position() mod 2)=1]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
And I should see "1" in the "//tbody/tr[(position() mod 2)=0]/child::td[contains(concat(' ', normalize-space(@class),' '),' numviews ')]" "xpath_element"
@javascript
Scenario: View the outline report when no log reader is enabled

View File

@ -18,15 +18,15 @@ information provided here is intended especially for theme designer.
* CSS related functions in theme class and csslib.php were refactored, addons that are
using this private API need to be updated
* Please update your css to use 'tr:nth-of-type(odd/even)' instead of '.ro/.r1' to apply tr specific css for various tables.
* Please update your css to use 'tr:nth-of-type(odd/even)' instead of '.r0/.r1' to apply tr specific css for various tables.
These classes are deprecated now and will be removed in Moodle 2.9. This has done to better support styling tables that will be altered by JavaScript.
Here is an example to update your css:
Old code:
table.generaltable .r0 {background-color: #F0F0F0;}
table.generaltable .r1 {background-color: #F0F0F0;}
New code:
table.generaltable > tbody > tr:nth-of-type(odd) {background-color: #F0F0F0;}
table.generaltable > tbody > tr:nth-of-type(even) {background-color: #F0F0F0;}
table.generaltable > tbody > tr:nth-of-type(odd) {background-color: #F0F0F0;}
Removed themes:
* afterburner, anomaly, arialist, binarius, boxxie, brick, formal_white, formfactor, fusion, leatherbound,