amatriain/feedbunch

View on GitHub
FeedBunch-app/app/assets/javascripts/ng-services/ng-FavicoSvc.js.coffee

Summary

Maintainability
Test Coverage
########################################################
# AngularJS service to change the favicon
########################################################

angular.module('feedbunch').service 'favicoSvc',
['$rootScope', '$window', 'unreadCountSvc', ($rootScope, $window, unreadCountSvc)->

  #---------------------------------------------
  # Set the current total unread entries count in the favicon badge.
  #---------------------------------------------
  update_unread_badge: ->
    # Only one Favico object must exist
    if !$rootScope.favico?
      $rootScope.favico = new Favico animation: 'none', bgColor: '#fff', textColor: '#404040'
    unread_count = unreadCountSvc.total_unread_entries()
    $rootScope.favico.badge unread_count
    $window.document.title = "(#{unread_count}) FeedBunch"

]