]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Refactor window blur/focus code in order to allow windows to receive notification...
authorChris Porter <redacted>
Mon, 22 Jun 2009 00:36:18 +0000 (01:36 +0100)
committerChris Porter <redacted>
Mon, 22 Jun 2009 00:36:18 +0000 (01:36 +0100)
js/ui/baseui.js
js/ui/baseuiwindow.js
js/ui/notifications.js
js/ui/panes/options.js

index 3801b4c503a155f4d13f09405b5f9f2a13693d99..d91d5ffa55448c6f5b8f2c0ede435750b047b429 100644 (file)
@@ -23,6 +23,10 @@ qwebirc.ui.BaseUI = new Class({
     this.firstClient = false;
     this.commandhistory = new qwebirc.irc.CommandHistory();
     this.clientId = 0;
+    
+    this.windowFocused = true;
+    window.addEvent("blur", function() { if(this.windowFocused) { this.windowFocused = false; this.focusChange(false); } }.bind(this));
+    window.addEvent("focus", function() { if(!this.windowFocused) { this.windowFocused = true; this.focusChange(true); } }.bind(this));
   },
   newClient: function(client) {
     client.id = this.clientId++;
@@ -151,6 +155,11 @@ qwebirc.ui.BaseUI = new Class({
     */
   loginBox: function(callback, initialNickname, initialChannels, autoConnect, autoNick) {
     qwebirc.ui.GenericLoginBox(this.parentElement, callback, initialNickname, initialChannels, autoConnect, autoNick, this.options.networkName);
+  },
+  focusChange: function(newValue) {
+    var window_ = this.getActiveWindow();
+    if($defined(window_))
+      window_.focusChange(newValue);
   }
 });
 
@@ -325,6 +334,10 @@ qwebirc.ui.NotificationUI = new Class({
   updateTitle: function(text) {
     if(this.__flasher.updateTitle(text))
       this.parent(text);
+  },
+  focusChange: function(value) {
+    this.parent(value);
+    this.__flasher.focusChange(value);
   }
 });
 
index 90e8b0f244db900a5ac5924da4379d18eac3e678..4b67558d796389d1ebfcfc644d054d2f60d13206 100644 (file)
@@ -228,5 +228,16 @@ qwebirc.ui.Window = new Class({
   historyExec: function(line) {
     this.commandhistory.addLine(line);
     this.client.exec(line);
-  }  
+  },
+  focusChange: function(newValue) {
+    console.log("focus change: " + newValue);
+    if(newValue == true || !(this.type & qwebirc.ui.WINDOW_LASTLINE))
+      return;
+      
+    if(this.lastPositionLineInserted)
+      this.lines.removeChild(this.lastPositionLine);
+      
+    if(this.parentObject.uiOptions.LASTPOS_LINE)
+      this.lines.appendChild(this.lastPositionLine);
+  }
 });
index 09b21b83348dfffe041d6ddceeba4e77a9e79e82..9aa5ab39969373f0e512d9005827c6d601c9ae8f 100644 (file)
@@ -66,9 +66,6 @@ qwebirc.ui.Flasher = new Class({
       \r
       this.flashing = false;\r
     \r
-      window.addEvent("focus", function() { this.windowFocused = true; this.cancelFlash(); }.bind(this));\r
-      window.addEvent("blur", function() { this.windowFocused = false; }.bind(this));\r
-      \r
       this.canFlash = true;\r
     } else {\r
       this.canFlash = false;\r
@@ -128,5 +125,9 @@ qwebirc.ui.Flasher = new Class({
   updateTitle: function(text) {\r
     this.titleText = text;\r
     return this.canUpdateTitle;\r
+  },\r
+  focusChange: function(value) {\r
+    if(value)\r
+      this.cancelFlash();\r
   }\r
 });\r
index e06e99108bc06bb374bb2e2e5ae5f306ce98efb7..a8b7c9352a19700c62624e02abf798fd0e24eabc 100644 (file)
@@ -31,7 +31,7 @@ qwebirc.config.DEFAULT_OPTIONS = [
   [3, "NICK_OV_STATUS", "Show status (@/+) before nicknames in nicklist", true],
   [5, "ACCEPT_SERVICE_INVITES", "Automatically join channels when invited by Q", true],
   [6, "USE_HIDDENHOST", "Hide your hostmask when authed to Q (+x)", true],
-  [8, "LASTPOS_LINE", "Show a last position indicator for each window.", true]
+  [8, "LASTPOS_LINE", "Show a last position indicator for each window", true]
 ];
 
 qwebirc.config.DefaultOptions = null;