SHARE
TWEET

AgilePoint - Collapsible Subsections with Checkboxes

a guest Jan 28th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function CollapseExpandSubSections() {
  2.     var checkboxParents = document.querySelectorAll('div.subFormContent[isexpandable="true"] > .subFormContentRow');
  3.    
  4.     var checkboxParentsLen = checkboxParents.length;
  5.     var allChecked;
  6.     var elem;
  7.     var thisSubform;
  8.     var checkboxes;
  9.     var subformLen;
  10.     for (var index = 0; index < checkboxParentsLen; index++) {
  11.         allChecked = true;
  12.        
  13.         thisSubform = $(checkboxParents[index]);
  14.         checkboxes = thisSubform.find('input[type="checkbox"]').not('input[type="checkbox"][disabled="disabled"]');
  15.         subformLen = checkboxes.length;
  16.         for (var checkboxIndex = 0; checkboxIndex < subformLen; checkboxIndex++) {
  17.             if (!checkboxes.eq(checkboxIndex).is(":checked")) {
  18.                 allChecked = false;
  19.                 break;
  20.             }
  21.         }
  22.        
  23.        
  24.         elem = checkboxParents[index];
  25.         if (allChecked) {
  26.             Collapse(elem);
  27.         }
  28.         else {
  29.             Expand(elem);
  30.         }
  31.     }
  32.    
  33.     function Collapse(elem) {
  34.         if (elem.className.indexOf("subFormCollapsedRow") === -1) {
  35.             $(elem).children(".subFormRowHeader").trigger("click");
  36.         }
  37.     }
  38.     function Expand(elem) {
  39.         if (elem.className.indexOf("subFormCollapsedRow") > -1) {
  40.             $(elem).children(".subFormRowHeader").trigger("click");
  41.         }
  42.     }
  43.     function Toggle(elem) {
  44.         $(elem).children(".subFormRowHeader").trigger("click");
  45.     }
  46. }
  47.  
  48. function MoveCheckboxSubformLabels() {
  49.     var checkboxParents = document.querySelectorAll('div.subFormContent[isexpandable="true"]');
  50.     checkboxParents = $(checkboxParents).parents('.previewRowContainer[id^="previewRow"]');
  51.     var textNode;
  52.     var text;
  53.     for (var index = checkboxParents.length; index > -1; index--) {
  54.         textNode = checkboxParents.eq(index).find("div.control.subFormControl > label.block.label > span").eq(0);
  55.         text = textNode.contents().text();
  56.         textNode.parent().remove();
  57.        
  58.         $("<span>" + text + "</span>").insertBefore( checkboxParents.eq(index).find("div.subFormRowHeader").eq(0).children().eq(0) );
  59.     }
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top