Highlight sounds
authorDarren <darren@Darrens-MacBook-Pro.local>
Fri, 5 Apr 2013 20:49:56 +0000 (21:49 +0100)
committerDarren <darren@Darrens-MacBook-Pro.local>
Fri, 5 Apr 2013 20:49:56 +0000 (21:49 +0100)
client/assets/dev/view.js

index 407c660e4d2df13cd0625551d337139eacf37234..dcc161b0302dffc9a5898f3d5cfbb5579420a606 100644 (file)
@@ -442,6 +442,7 @@ _kiwi.view.Panel = Backbone.View.extend({
 \r
         } else if (is_highlight) {\r
             _kiwi.app.view.alertWindow('* People are talking!');\r
+            _kiwi.app.view.playSound('highlight');\r
             this.alert('highlight');\r
 \r
         } else {\r
@@ -452,6 +453,11 @@ _kiwi.view.Panel = Backbone.View.extend({
             this.alert('activity');\r
         }\r
 \r
+        if (this.model.isQuery() && !this.model.isActive()) {\r
+            _kiwi.app.view.alertWindow('* People are talking!');\r
+            _kiwi.app.view.playSound('highlight');\r
+        }\r
+\r
         // Update the activity counters\r
         (function () {\r
             // Only inrement the counters if we're not the active panel\r
@@ -1159,6 +1165,8 @@ _kiwi.view.Application = Backbone.View.extend({
                 return 'This will close all KiwiIRC conversations. Are you sure you want to close this window?';\r
             }\r
         };\r
+\r
+        this.initSound();\r
     },\r
 \r
 \r
@@ -1381,6 +1389,36 @@ _kiwi.view.Application = Backbone.View.extend({
             $('#controlbox').slideDown(0);\r
             this.doLayout();\r
         }\r
+    },\r
+\r
+\r
+    initSound: function () {\r
+        var that = this,\r
+            base_path = this.model.get('base_path');\r
+\r
+        $script(base_path + '/assets/libs/soundmanager2/soundmanager2-nodebug-jsmin.js', function() {\r
+            if (typeof soundManager === 'undefined')\r
+                return;\r
+\r
+            soundManager.setup({\r
+                url: base_path + '/assets/libs/soundmanager2/',\r
+                flashVersion: 9, // optional: shiny features (default = 8)// optional: ignore Flash where possible, use 100% HTML5 mode\r
+                preferFlash: true,\r
+\r
+                onready: function() {\r
+                    that.sound_object = soundManager.createSound({\r
+                        id: 'highlight',\r
+                        url: base_path + '/assets/sound/highlight.mp3'\r
+                    });\r
+                }\r
+            });\r
+        });\r
+    },\r
+\r
+\r
+    playSound: function (sound_id) {\r
+        if (!this.sound_object) return;\r
+        soundManager.play(sound_id);\r
     }\r
 });\r
 \r