{"size": 865, "ext": "js", "max_stars_repo_path": "app/js/view/medListItem.js", "max_stars_repo_name": "keithb418/medcheckerapp", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/js/view/medListItem.js", "max_issues_repo_name": "keithb418/medcheckerapp", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app/js/view/medListItem.js", "max_forks_repo_name": "keithb418/medcheckerapp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.2121212121, "max_line_length": 63, "alphanum_fraction": 0.5791907514}
define(function (require) {
  'use strict';
  var App = require('app');
  var template = require('text!../../html/med-list-item.html');

  return Backbone.Marionette.ItemView.extend({
	  tagName: 'li',
    className: 'med-list-item',
    template: _.template(template),
    events: {
      'change input': 'updateAction',
      'click button': 'viewMedLabel'
    },
    updateAction: function (e) {
      var $target = this.$el.find(e.currentTarget);
      var checked = $target.is(':checked');
      var id = $target.attr('id');
      
      if (checked) {
        App.selectedMeds.push(id);
      } else {
        var index = App.selectedMeds.indexOf(id);
        App.selectedMeds.splice(index, 1);
      }
      
      App.vent.trigger('update:action');
    },
    viewMedLabel: function () {
      App.vent.trigger('show:medLabel', this.model);
    }
  });
});
