]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/baseui.js
Refactor beeping into seperate class, and rename SoundUI to NotificationUI.
[irc/quakenet/qwebirc.git] / js / ui / baseui.js
index a61da847a4c67b9609d0a4f243452d6b9247fc2f..a3aec90527b34827d51ea2a704fd878a114f3438 100644 (file)
@@ -93,7 +93,10 @@ qwebirc.ui.BaseUI = new Class({
     if(this.active)
       this.active.deselect();
     window.select();  /* calls setActiveWindow */
-    document.title = window.name + " - " + this.options.appTitle;
+    this.updateTitle(window.name + " - " + this.options.appTitle);
+  },
+  updateTitle: function(text) {
+    document.title = text;
   },
   nextWindow: function(direction) {
     if(this.windowArray.length == 0 || !this.active)
@@ -301,44 +304,31 @@ qwebirc.ui.StandardUI = new Class({
   }
 });
 
-qwebirc.ui.SoundUI = new Class({
+qwebirc.ui.NotificationUI = new Class({
   Extends: qwebirc.ui.StandardUI,
   initialize: function(parentElement, windowClass, uiName, options) {
     this.parent(parentElement, windowClass, uiName, options);
     
-    this.soundInited = false;
-    this.soundReady = false;
+    this.__beeper = new qwebirc.ui.Beeper(this.uiOptions);
+    this.__flasher = new qwebirc.ui.Flasher(this.uiOptions);
     
-    this.setBeepOnMention(this.uiOptions.BEEP_ON_MENTION);    
-  },
-  soundInit: function() {
-    if(this.soundInited)
-      return;
-    if(!$defined(Browser.Plugins.Flash) || Browser.Plugins.Flash.version < 8)
-      return;
-    this.soundInited = true;
+    this.beep = this.__beeper.beep.bind(this.__beeper);
     
-    this.soundPlayer = new qwebirc.sound.SoundPlayer();
-    this.soundPlayer.addEvent("ready", function() {
-      this.soundReady = true;
-    }.bind(this));
-    this.soundPlayer.go();
+    this.flash = this.__flasher.flash.bind(this.__flasher);
+    this.cancelFlash = this.__flasher.cancelFlash.bind(this.__flasher);
   },
   setBeepOnMention: function(value) {
     if(value)
-      this.soundInit();
-    this.beepOnMention = value;
+      this.__beeper.soundInit();
+  },
+  updateTitle: function(text) {
+    if(this.__flasher.updateTitle(text))
+      this.parent(text);
   },
-  beep: function() {
-    if(!this.soundReady || !this.beepOnMention)
-      return;
-      
-    this.soundPlayer.beep();
-  }
 });
 
 qwebirc.ui.NewLoginUI = new Class({
-  Extends: qwebirc.ui.SoundUI,
+  Extends: qwebirc.ui.NotificationUI,
   loginBox: function(callbackfn, initialNickname, initialChannels, autoConnect, autoNick) {
     this.postInitialize();