PHP Classes

File: resources/views/backend/pages/roles/partials/scripts.blade.php

Recommend this page to a friend!
  Classes of Maniruzzaman Akash   LaraCMS   resources/views/backend/pages/roles/partials/scripts.blade.php   Download  
File: resources/views/backend/pages/roles/partials/scripts.blade.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: LaraCMS
Content management system based on Laravel
Author: By
Last change:
Date: 2 years ago
Size: 1,679 bytes
 

Contents

Class file image Download
<script>
    $("#allManagement").click(function() {
       if($(this).is(':checked'))
           $('input[type=checkbox]').prop('checked', true);
       else
           $('input[type=checkbox]').prop('checked', false);
   })

   /**
   * checkPrmissions()
   * Check and uncheck permissions
   */
   function checkPrmissions(className, checkThis) {
       const groupClassName = $('#'+checkThis.id);
       const classCheckbox = $('.'+className+'-checkbox input');

       if(groupClassName.is(':checked')) classCheckbox.prop('checked', true);
       else classCheckbox.prop('checked', false);
       implementAllChecked();
   }

   function checkSinglePrmission(className, groupID, countTotalPermission) {

       const classCheckbox = $('.'+className+'-checkbox input');
       const groupIDBox = $('#'+groupID);

       // if there is any occurance where somthing is not selected then make selected = false
       if($('.'+className+'-checkbox input:checked').length == countTotalPermission){
        groupIDBox.prop('checked', true);
       }else{
        groupIDBox.prop('checked', false);
       }
       implementAllChecked();
   }
  
   function implementAllChecked() {
       let countPermissions = <?php echo count($all_permissions); ?>;
       let countPermissionsGroup = <?php echo count($permissions_group); ?>;
      
       // if there is any occurance where somthing is not selected then make selected = false
       if($('input[type="checkbox"]:checked').length > (countPermissions + countPermissionsGroup)){
        $('#allManagement').prop('checked', true);
       }else{
        $('#allManagement').prop('checked', false);
       }
   }
</script>