         else
             if @popoverTarget?
                 @popoverTarget.field.popover('destroy')
-                pouet = true
-            else
-                pouet = false
 
             @popoverTarget =
                 field: $(target)

                button.addClass 'disabled'
            else
                button.removeClass 'disabled'

    onAdd: (alarm, alarms) ->


    afterRender: ->

        @cal = @$('#alarms').fullCalendar
            header:
                left: 'prev,next today'
                center: 'title'
                right: 'month,agendaWeek,agendaDay'
            editable: true
            firstDay: 1 # first day of the week is monday ffs
            weekMode: 'liquid'
            aspectRatio: 2.031
            defaultView: 'month'
            columnFormat:
                month: 'dddd'
                week: 'ddd dd/MM'
                day: 'dddd dd/MM'
            timeFormat:
                '': 'HH:mm'
                'agenda': 'HH:mm{ - HH:mm}'
            axisFormat: 'HH:mm'
            buttonText:
                today: 'Today'
                month: 'Month'
                week: 'Week'
                day: 'Day'
            selectable: true
            selectHelper: false
            unselectAuto: false
            viewDisplay: @viewDisplay
            eventRender: @eventRender
            eventDragStop: @eventDragStop
            # Manage persistance when an edit action is performed
            eventDrop: @eventDrop
            # To manage the selection
            select: @select
            eventClick: @eventClick

    viewDisplay: (view) =>
        if @popoverTarget
            @popoverTarget.field.popover('destroy')
            @popoverTarget = null

    eventRender: (event, element) ->
        # we don't want alarms to be resized
        if event.type is 'alarm'
            selector = '.ui-resizable-handle.ui-resizable-s'
            $(element).find(selector).remove()

        if event.isSaving? and event.isSaving
            spinTarget = $(element).find('.fc-event-time')
            spinTarget.addClass 'spinning'
            spinTarget.html "&nbsp;"
            spinTarget.spin "tiny"

        return element

    eventDragStop: (event, jsEvent, ui, view) ->
        #triggers the loading wheel
        event.isSaving = true

    eventDrop: (event, dayDelta, minuteDelta, allDay, revertFunc) =>

        alarm =  @model.get event.id
        alarm.getDateObject().advance
            days: dayDelta
            minutes: minuteDelta

        data = trigg: alarm.getFormattedDate Alarm.dateFormat
        alarm.save data,
            wait: true
            success: =>
                event.isSaving = false
                @cal.fullCalendar('renderEvent', event)
            error: ->
                event.isSaving = false
                @cal.fullCalendar('renderEvent', event)
                revertFunc()

    select: (startDate, endDate, allDay, jsEvent, view) =>
        if view.name is "month"
            @handleSelectionInView(startDate, endDate, allDay, jsEvent)
        else if view.name is "agendaWeek"
            @handleSelectionInView(startDate, endDate, allDay, jsEvent)
        else if view.name is "agendaDay"
            @handleSelectionInView(startDate, endDate, allDay, jsEvent, true)

    handleSelectionInView: (startDate, endDate, allDay, jsEvent, isDayView) ->

