CRM-15578 - crmUiAccordion - Basic implementation
authorTim Otten <totten@civicrm.org>
Thu, 30 Oct 2014 03:51:14 +0000 (20:51 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 11 Nov 2014 00:19:33 +0000 (16:19 -0800)
js/angular-crm-ui.js

index 502db3791960d4be6c16768b03de7955bd92b06a..571f56a699147558855bf100f4c4abd73a013d69 100644 (file)
@@ -4,15 +4,21 @@
 
   angular.module('crmUi', [])
 
-    // example <div crm-ui-accordion crm-title="ts('My Title')">...content...</div>
+    // example <div crm-ui-accordion crm-title="ts('My Title')" crm-collapsed="true">...content...</div>
+    // WISHLIST: crmCollapsed should support two-way/continous binding
     .directive('crmUiAccordion', function() {
       return {
         scope: {
-          crmTitle: '@'
+          crmTitle: '@',
+          crmCollapsed: '@'
         },
-        template: '<div><b>(Accordion: {{$parent.$eval(crmTitle)}})</b><span ng-transclude/></div>',
+        template: '<div class="crm-accordion-wrapper" ng-class="cssClasses"><div class="crm-accordion-header">{{$parent.$eval(crmTitle)}}</div><div class="crm-accordion-body" ng-transclude></div></div>',
         transclude: true,
-        link: function (scope, element, attrs) {}
+        link: function (scope, element, attrs) {
+          scope.cssClasses = {
+            collapsed: scope.$parent.$eval(attrs.crmCollapsed)
+          };
+        }
       };
     })