(function() {
  this.generalSiteHandler = function() {
    var bindFormHandler, bindInstructionListHandler;
    $(document).ready(function() {
      bindInstructionListHandler();
      return bindFormHandler();
    });
    bindInstructionListHandler = function() {
      return $('.instruction-list__title').on('click', function() {
        return $('.instruction-list__content__item').stop().toggle(function() {
          $('.instruction-list').toggleClass('show');
        });
      });
    };
    return bindFormHandler = function() {
      (function() {
        return $('input').each(function() {
          if ($(this).val() !== '') {
            $(this).siblings('label').css({
              'bottom': '45px',
              'font-size': '13px'
            });
          }
          if ($(this).parent().hasClass('has-error')) {
            return $(this).siblings('label').css({
              'bottom': '65px',
              'font-size': '13px'
            });
          }
        });
      })();
      return $('input').on('change', function() {
        if ($(this).val() !== '') {
          $(this).siblings('label').css({
            'bottom': '45px',
            'font-size': '13px'
          });
        } else {
          $(this).siblings('label').css({
            'bottom': '',
            'font-size': '13px'
          });
        }
        if ($(this).parent().hasClass('has-error')) {
          return $(this).siblings('label').css({
            'bottom': '65px',
            'font-size': '13px'
          });
        }
      });
    };
  };

  this.userProfileHandler = function() {
    var onDocumentReady;
    onDocumentReady = function() {
      $('.edit-save-button').on('click', function() {
        $(this).hide();
        $(this).parent().find('button').show();
        return $(this).parent().find('input').prop('readonly', false);
      });
      $('.password-edit-view').on('click', function() {
        return $('.new-password-2-wrapper').show();
      });
      return $('.username-edit-view').on('click', function() {
        return $('.username-hint-wrapper').show();
      });
    };
    return $(document).ready(onDocumentReady);
  };

  this.popupHandler = function() {
    var onDocumentReady;
    onDocumentReady = function() {
      return $('.popup-close-button').on('click', function() {
        return $('.popup-container').hide();
      });
    };
    return $(document).ready(onDocumentReady);
  };

  this.exerciseHandler = function() {
    var onDocumentReady;
    onDocumentReady = function() {
      var exerciseDoneCallback;
      exerciseDoneCallback = function(data) {
        if (data.status) {
          if (data.status === 'all_done') {
            $('.todo-notification').hide();
            $('.all-done-notification').show();
          }
          if (data.status === 'done') {
            $('.todo-notification').hide();
            $('.done-notification').show();
          }
          if (data.progress) {
            return $('.exercises-progress-content').html(data.progress + '%');
          }
        }
      };
      return $('.exercise-done-button').on('click', function() {
        var exercise_task_position_id;
        exercise_task_position_id = $(this).data('extra-arg');
        return Dajaxice.exercises.exercise_done(exerciseDoneCallback, {
          'exercise_task_position_id': exercise_task_position_id
        });
      });
    };
    return $(document).ready(onDocumentReady);
  };

  this.likesHandler = function() {
    var onDocumentReady;
    onDocumentReady = function() {
      var sendLikesCallback;
      sendLikesCallback = function(data) {
        if (data.status) {
          if (data.status === 'ok') {
            return $('.social-vote-content').html(data.social_vote_list_html);
          }
        }
      };
      $('.like-button').on('click', function() {
        return $(this).parent().toggleClass('voted');
      });
      return $('.send-likes').on('click', function() {
        var taskAnswerId, taskMarkCriteriaIds;
        taskMarkCriteriaIds = [];
        taskAnswerId = $('.send-likes').data('task-answer-id');
        $('.voted').each((function(_this) {
          return function(index, element) {
            var id;
            id = $(element).data('task-mark-criteria-id');
            return taskMarkCriteriaIds.push(id);
          };
        })(this));
        return Dajaxice.tasks.submit_likes(sendLikesCallback, {
          'task_mark_criteria_ids': taskMarkCriteriaIds,
          'task_answer_id': taskAnswerId
        });
      });
    };
    return $(document).ready(onDocumentReady);
  };

  this.taskAnswerListHeaderHandler = function() {
    var onDocumentReady;
    onDocumentReady = function() {
      $('#queryInput').keyup(function(e) {
        if (e.which === 13) {
          $('#sortHeaderForm').submit();
          return false;
        }
      });
      $('#pathSelect').change(function() {
        $('#sortHeaderForm').submit();
        return false;
      });
      $('#sortSelect').change(function() {
        $('#sortHeaderForm').submit();
        return false;
      });
      return $('.more-button').click(function() {
        $('#moreInput').val(true);
        return $('#sortHeaderForm').submit();
      });
    };
    return $(document).ready(onDocumentReady);
  };

}).call(this);

//# sourceMappingURL=main.js.map
