//= require shared
//= require moment 
//= require fullcalendar

function eventCalendar() {
  return $('#calendar').fullCalendar({ events: '/objectives/goals.json' });
};

function clearCalendar() {
  $('#calendar').fullCalendar('delete'); // In case delete doesn't work.
  $('#calendar').html('');
};

$(document).on('turbolinks:load', eventCalendar);
$(document).on('turbolinks:before-cache', clearCalendar)


$(document).on('turbolinks:load', function() {
  // Hide/Show goal block
  $('#goal-hide-btn').on('click', function(e) {
    var buttonIcon = $('#hide-btn-icon')
    var iconUp     = buttonIcon.hasClass('fa-chevron-up')
    var iconDown   = buttonIcon.hasClass('fa-chevron-down')

    e.preventDefault();
    $('#goal-description').slideToggle('fast');
    
    if (iconUp) {
      buttonIcon.removeClass();
      buttonIcon.addClass('fa fa-chevron-down text-primary');
    } else if (iconDown) { 
      buttonIcon.removeClass();
      buttonIcon.addClass('fa fa-chevron-up');
    }
  });

  // Tasks block
  setActiveTab();

  function setActiveTab() {
    var goalActionsTab  = $('#goal-actions-tab')
    var goalTasksTab    = $('#goal-tasks-tab')
    var storageTabState = localStorage.getItem('goalActiveTab')

    if (storageTabState == 'goal-actions-tab') {
      goalActionsTab.click();
    } else if (storageTabState == 'goal-tasks-tab') {
      goalTasksTab.click();
    };
  };

  $('.goal-content-tab').on('click', function() {
    localStorage.setItem('goalActiveTab', this.id)
  });
});
@@ -484,56 +484,131 @@
 k%0A  
-$
+var goalVisibilityState = localStorage.getItem
 ('
-#
 goal
--hide-btn').on('click', function(e) %7B%0A  
+ContentVisibility')%0A  var goalContentBlock    = $('#goal-description')%0A
   va
@@ -620,16 +620,25 @@
 tonIcon 
+         
 = $('#hi
@@ -655,238 +655,738 @@
 n')%0A
+%0A
   
-  var iconUp     = buttonIcon.hasClass('fa-chevron-up')%0A    var iconDown   = buttonIcon.hasClass('fa-chevron-down')%0A%0A    e.preventDefault();%0A    $('#goal-description').slideToggle('fast');%0A    %0A    if (iconUp) %7B%0A      buttonIcon
+goalContentVisibility();%0A%0A  function changeGoalBlockIcon(icon_class) %7B%0A    buttonIcon.removeClass();%0A    buttonIcon.addClass(icon_class);%0A  %7D%0A%0A  function goalContentVisibility() %7B%0A    if (goalVisibilityState == 'hidden') %7B%0A      goalContentBlock.addClass('hidden');%0A      changeGoalBlockIcon('fa fa-chevron-down text-primary');%0A%0A    %7D else if (goalVisibilityState == 'visible') %7B%0A      goalContentBlock.removeClass('hidden');%0A      changeGoalBlockIcon('fa fa-chevron-up');%0A    %7D;%0A  %7D;%0A%0A  $('#goal-hide-btn').on('click', function(e) %7B%0A    e.preventDefault();%0A    $('#goal-description').slideToggle('fast');%0A    %0A    if (goalContentBlock.hasClass('hidden')) %7B%0A      changeGoalBlockIcon('fa fa-chevron-up');%0A      goalContentBlock
 .rem
@@ -1386,32 +1386,40 @@
 ock.removeClass(
+'hidden'
 );%0A      buttonI
@@ -1415,170 +1415,246 @@
     
-buttonIcon.addClass('fa fa-chevron-down text-primary');%0A    %7D else if (iconDown) %7B %0A      buttonIcon.removeClass();%0A      buttonIcon.addClass('fa fa-chevron-up
+localStorage.setItem('goalContentVisibility', 'visible')%0A%0A    %7D else %7B %0A      changeGoalBlockIcon('fa fa-chevron-down text-primary');%0A      goalContentBlock.addClass('hidden');%0A      localStorage.setItem('goalContentVisibility', 'hidden
 ')
-;
 %0A   

Write some additional js code for goal block visibility