]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added ability to check all rows or columns in ecml permissions page.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 15 Apr 2010 23:24:10 +0000 (23:24 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 15 Apr 2010 23:24:10 +0000 (23:24 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@5758 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/ecml/views/default/ecml/admin/ecml_admin.php

index 34f7774141b83fb95a72d265360172d7743d91d4..0bd7793c8c189f19a5a14963d4f109161daee396 100644 (file)
@@ -27,7 +27,8 @@ $form_body = <<<___END
 ___END;
 
 foreach ($views as $view => $view_desc) {
-       $form_body .= "<th><acronym title=\"$view\">$view_desc</acronym></th>";
+       $form_body .= "<th><acronym class=\"ecml_view ecml_check_all\" title=\"$view\">$view_desc</acronym></th>";
+       $n++;
 }
 $form_body .= '</tr>';
 
@@ -36,7 +37,7 @@ foreach ($keywords as $keyword => $keyword_info) {
        $keyword_desc = $keyword_info['description'];
        $form_body .= "
        <tr class=\"ecml_row_$odd\">
-               <td class=\"ecml_keyword_desc\"><acronym title=\"$keyword_desc\">$keyword</acryonym></td>
+               <td class=\"ecml_keyword_desc\"><acronym class=\"ecml_keyword ecml_check_all\" title=\"$keyword_desc\">$keyword</acronym></td>
 ";
        foreach ($views as $view => $view_info) {
                // if this is restricted and we're not on the specified view don't allow changes
@@ -65,21 +66,34 @@ echo elgg_view('input/form', array(
        'action' => $vars['url'] . 'action/ecml/save_permissions'
 ));
 
-//foreach ($views as $view => $desc) {
-//     echo elgg_view_title($desc);
-//     echo '<ul>';
-//     foreach ($keywords as $keyword => $info) {
-//             $description = $info['description'];
-//
-//             echo "<li>$keyword</li>";
-//     }
-//     echo '</ul>';
-//
-//echo <<<___END
-//     <br />
-//     </li>
-//
-//___END;
-//}
-//
-//echo '</ul>';
\ No newline at end of file
+?>
+<script type="text/javascript">
+
+$(document).ready(function() {
+       // append check all link
+       $('.ecml_check_all').before('<input type="checkbox" class="check_all">');
+
+       $('input.check_all').click(function() {
+               // yoinked from
+               // http://stackoverflow.com/questions/788225/table-row-and-column-number-in-jquery
+               var rowIndex = $(this).parent().parent().children().index($(this).parent());
+               var check = $(this).attr('checked');
+
+               // clicked on a keyword on the left, check all boxes in the tr
+               if (rowIndex == 0) {
+                       $(this).parent().parent().find('input').each(function() {
+                               if (!$(this).attr('disabled')) {
+                                       $(this).attr('checked', check);
+                               }
+                       });
+               } else {
+                       boxes = $('.ecml_admin_table > tbody > tr td:nth-child(' + (rowIndex + 1) + ') input[type=checkbox]');
+                       boxes.each(function() {
+                               if (!$(this).attr('disabled')) {
+                                       $(this).attr('checked', check);
+                               }
+                       });
+               }
+       });
+});
+</script>