Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Improving row selection in Joomla! Admin #14913

Merged
merged 8 commits into from
Apr 1, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions administrator/templates/atum/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ $fa-font-path: "../../../../media/vendor/font-awesome/fonts"
// Tables
$table-bg: transparent !default;
$table-bg-accent: rgba(0,0,0,.03) !default;
$table-row-selected #d9edf7;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a colon after the variable name, like so: $table-row-selected:


// Tabs
$atum-tabs-header-bg: $atum-block-header-bg;
Expand Down
3 changes: 3 additions & 0 deletions administrator/templates/atum/scss/template.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
box-shadow: 0 0 3px rgba(0,0,0,.075);
}

.row-selected {
background-color: $table-row-selected;
}

// Chosen (TEMPORARY)
.chzn-container-single {
Expand Down
45 changes: 45 additions & 0 deletions media/system/js/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,48 @@ Joomla.JMultiSelect = function(table) {
};
initialize(table);
};

document.addEventListener("DOMContentLoaded", function(event) {
color = '#d9edf7';
rows = document.querySelectorAll('tr[class^="row"]');
Copy link
Member

@C-Lodder C-Lodder Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to:

var colour = '#d9edf7',
    rows   = document.querySelectorAll('tr[class^="row"]');

Note, the British spelling of colour


// Changes the background-color on every <td> inside a <tr>
function changeBg(item, color) {
item.querySelectorAll('td').forEach (function(td) {
td.style.backgroundColor = color;
});
}

document.getElementsByName("checkall-toggle")[0].addEventListener("click", function(event) {
if (this.checked) {
rows.forEach(function(row, index) {
changeBg(row, color);
});
}
else {
rows.forEach(function(row, index) {
changeBg(row, '');
});
}
Copy link
Member

@C-Lodder C-Lodder Mar 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can simplify this if - else statement to just:

var colour = this.checked ? colour : '';

rows.forEach(function(row, index) {
	changeBg(row, colour);
});

});

rows.forEach(function(row, index) {
row.addEventListener("click", function(event) {
clicked = 'cb' + index;
cbClicked = document.getElementById(clicked);

if (!(event.target.id == clicked)) {
cbClicked.checked = !cbClicked.checked;
Joomla.isChecked(cbClicked.checked);
}

if (cbClicked.checked) {
changeBg(this, color);
}
else {
changeBg(this, '');
}
});
});
});

2 changes: 1 addition & 1 deletion media/system/js/multiselect.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.