'use strict';

angular.module('arethusa.core').directive('sidepanelFolder', [
  'sidepanel',
  function(sidepanel) {
    return {
      scope: {},
      link: function (scope, element, attrs) {
        function setIconClass() {
          var icon = sidepanel.folded ? 'compress' : 'expand';
          scope.iconClass = 'fi-arrows-' + icon;
        }

        element.on('click', function () {
          sidepanel.toggle();
          setIconClass();
        });

        scope.sp = sidepanel;

        scope.$watch('sp.folded', function(newVal, oldVal) {
          setIconClass();
        });
      },
      template: '<i ng-class="iconClass"/>'
    };
  }
]);

@@ -216,16 +216,23 @@
 conClass
+AndText
 () %7B%0A   
@@ -273,26 +273,83 @@
  ? '
-compress' : 'expan
+expand' : 'compress';%0A          var text = sidepanel.folded ? 'Show' : 'Fol
 d';%0A
@@ -397,16 +397,56 @@
 + icon;%0A
+          scope.text = text + %22 Panel%22;%0A
         
@@ -522,32 +522,45 @@
 le();%0A          
+scope.$apply(
 setIconClass();%0A
@@ -547,33 +547,41 @@
 ply(setIconClass
-(
+AndText()
 );%0A        %7D);%0A%0A
@@ -694,16 +694,23 @@
 conClass
+AndText
 ();%0A    
@@ -745,16 +745,35 @@
 ate: '%3Ci
+ title=%22%7B%7B text %7D%7D%22
  ng-clas

Fix sidepanel-folder class and title text