# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

$(document).ready ->
  $('.event-container').popover
    trigger: 'click'
    html: true
    placement: 'top'
    title: ->
      return $('.popover-title', $(@)).html()
    content: ->
      return $('.popover-content', $(@)).html()
  .click (e) ->
    $("body").addClass('aw-popover');
    $('.event-container').not(@).popover('hide')
    e.stopPropagation()

  $(document).on('click', '.close-popover', ( (e)->
    $('.event-container').popover('hide')
  ));

  $(document).on('click', '.close-modal', ( (e)->
    $('.modal').modal('hide')
  ));

  $(document).on('click', '.event-container', ( (e)->
    $('.event-container').not(@).popover('hide')
  ));

  $(document).on('click', '.aw-popover', ( (e)->
    $('.event-container').not(@).popover('hide')
    $(this).removeClass()
  ));



  $('.button-login').popover
    trigger: 'click'
    html: true
    placement: 'bottom'
    title: ->
      return $('.login-title').html()
    content: ->
      return $('.login-content').html()
