     teaSelection.init()
 )
 
-angular.module('tea').controller("ControlPanelController", ($scope, $timeout, teaSelection, localize) ->
+angular.module('tea').controller("ControlPanelController", ($scope, $timeout, teaSelection, localize, Notification) ->
     self = this
 
     $scope.radio = {index: 0}

            resetTitle()
            #Display notification only if timer enabled!
            if $scope.timer
                Utils.displayNotification(localize.getLocalizedString('_AppTitle_'),
                    localize.getLocalizedString('_NotificationMessage_'))

    updateTitle = (time) ->



    this.setFromSelection(teaSelection.getSelection())
)

angular.module('tea').service('Notification', ($timeout) ->
    snd = new Audio('snd/alarm.mp3')
    popup = null
    service = {}

    service.supported = () ->
        Notification

    service.checkPermission = () ->
        Notification.requestPermission() unless Notification.permission is "granted"

    service.display = (title, message) ->
        popup = new Notification(title, {
            body: message
            icon: "img/icon.png"
        })
        snd.play() if SOUND

        popup.onclick = () ->
            popup.close()

        popup.onclose = () ->
            snd.pause()

        $timeout(() ->
            #hide notification and stop sound
            cancel()
        , CANCEL_TIMEOUT)

    cancel = () ->
        popup.close() if popup
        snd.pause()


    return service
)

angular.module('tea').controller("RootController", ($scope, Notification) ->
    $scope.notificationSupported = Notification.supported
)

#Utils
