diff --git a/app/assets/javascripts/app/controllers/navigation.js.coffee b/app/assets/javascripts/app/controllers/navigation.js.coffee index 6b999fe77..f29a844ab 100644 --- a/app/assets/javascripts/app/controllers/navigation.js.coffee +++ b/app/assets/javascripts/app/controllers/navigation.js.coffee @@ -39,6 +39,11 @@ class App.Navigation extends App.Controller @bind 'bell', (data) => if data is 'on' @el.find('.bell').addClass('show') + App.Audio.play( 'https://www.sounddogs.com/previews/2193/mp3/219024_SOUNDDOGS__be.mp3' ) + @delay( + -> App.Event.trigger('bell', 'off' ) + 3000 + ) else @el.find('.bell').removeClass('show') diff --git a/app/assets/javascripts/app/lib/app_post/audio.js.coffee b/app/assets/javascripts/app/lib/app_post/audio.js.coffee new file mode 100644 index 000000000..18df30b58 --- /dev/null +++ b/app/assets/javascripts/app/lib/app_post/audio.js.coffee @@ -0,0 +1,12 @@ +class App.Audio + @play: ( url, volume = 0.1 ) -> + return if !window.Audio + audio = new window.Audio() + return if !audio.canPlayType + canPlay = audio.canPlayType('audio/mp3') + return if canPlay isnt 'maybe' and canPlay isnt 'probably' + $(audio).prop( 'src', url ) + audio.load(); + audio.preload = "auto"; + audio.volume = volume; + audio.play()