Quellcode durchsuchen

Merge pull request #2058 from EmmanuelVella/list-checkboxes

Update list checkbox js + css
Thomas vor 11 Jahren
Ursprung
Commit
929fcf0fd4
2 geänderte Dateien mit 18 neuen und 16 gelöschten Zeilen
  1. 2 11
      Resources/public/css/layout.css
  2. 16 5
      Resources/views/CRUD/base_list.html.twig

+ 2 - 11
Resources/public/css/layout.css

@@ -71,17 +71,8 @@ h4.filter_legend table {
 }
 
 
-
-.zebra-striped tbody tr.sonata-ba-list-row-selected td, .zebra-striped tbody tr.sonata-ba-list-row-selected th {
-    background-color: #fcffc4;
-}
-
-.zebra-striped tbody tr.sonata-ba-list-row-selected:nth-child(odd) td, .zebra-striped tbody tr.sonata-ba-list-row-selected:nth-child(odd) th {
-    background-color: #faff9e;
-}
-
-.zebra-striped tbody tr.sonata-ba-list-row-selected:hover td, .zebra-striped tbody tr.sonata-ba-list-row-selected:hover th {
-    background-color: #fdffd8;
+.table-striped tbody tr.sonata-ba-list-row-selected td, .table-striped tbody tr.sonata-ba-list-row-selected th {
+    background-color: #E3F7FE;
 }
 
 table.sonata-ba-list td img {

+ 16 - 5
Resources/views/CRUD/base_list.html.twig

@@ -89,12 +89,23 @@ file that was distributed with this source code.
                                                     <script>
                                                         {% block batch_javascript %}
                                                             jQuery(document).ready(function ($) {
-                                                                $('#list_batch_checkbox').click(function () {
-                                                                    $(this).closest('table').find("td input[type='checkbox']").attr('checked', $(this).is(':checked')).parent().parent().toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'));
-                                                                });
-                                                                $("td.sonata-ba-list-field-batch input[type='checkbox']").change(function () {
-                                                                    $(this).parent().parent().toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'));
+                                                                $('#list_batch_checkbox').on('ifChanged', function () {
+                                                                    $(this)
+                                                                        .closest('table')
+                                                                        .find('td.sonata-ba-list-field-batch input[type="checkbox"]')
+                                                                        .iCheck($(this).is(':checked') ? 'check' : 'uncheck')
+                                                                    ;
                                                                 });
+
+                                                                $('td.sonata-ba-list-field-batch input[type="checkbox"]')
+                                                                    .on('ifChanged', function () {
+                                                                        $(this)
+                                                                            .closest('tr')
+                                                                            .toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'))
+                                                                        ;
+                                                                    })
+                                                                    .trigger('ifChanged')
+                                                                ;
                                                             });
                                                         {% endblock %}
                                                     </script>