[Vtigercrm-commits] [vtiger-commits] r7902 - /branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Fri Jul 7 16:05:17 EDT 2006
Author: mmbrich
Date: Fri Jul 7 14:05:16 2006
New Revision: 7902
Log:
cross tab/window focus checks
Modified:
branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/include/js/objects/CommSystem.js Fri Jul 7 14:05:16 2006
@@ -14,6 +14,7 @@
this.keytimer;
this.user=CurrentUser;
this.tmpCount=0;
+ this.Focused='true';
},
/*
@@ -23,26 +24,31 @@
*/
CommUpdate: function() {
globalCommSystem = this;
- window.clearTimeout(globalCommSystem.timer);
- if(globalCommSystem.tmpCount == 0 || typeof(globalCommSystem.tmpCount) == "undefined") {
- var first = 'true';
- globalCommSystem.tmpCount++;
+ if(globalCommSystem.Focused == 'false') {
+ window.clearTimeout(globalCommSystem.timer);
+ globalCommSystem.timer = window.setTimeout('globalCommSystem.CommUpdate()',globalCommSystem.refreshtime);
} else {
- var first = 'false';
- globalCommSystem.tmpCount++;
- }
- new Ajax.Request(
- 'index.php',
- {queue: {position: 'end', scope: 'commsys'},
- method: 'post',
- postBody: 'module=CommSystem&action=CommSystemAjax&command=getPeriodicalInfo&first_load='+first,
- onComplete: globalCommSystem.HandleEvent,
- onFailure: function() {
- alert("Failed");
- window.clearTimeout(globalCommSystem.timer);
+ window.clearTimeout(globalCommSystem.timer);
+ if(globalCommSystem.tmpCount == 0 || typeof(globalCommSystem.tmpCount) == "undefined") {
+ var first = 'true';
+ globalCommSystem.tmpCount++;
+ } else {
+ var first = 'false';
+ globalCommSystem.tmpCount++;
+ }
+ new Ajax.Request(
+ 'index.php',
+ {queue: {position: 'end', scope: 'commsys'},
+ method: 'post',
+ postBody: 'module=CommSystem&action=CommSystemAjax&command=getPeriodicalInfo&first_load='+first,
+ onComplete: globalCommSystem.HandleEvent,
+ onFailure: function() {
+ alert("Failed");
+ window.clearTimeout(globalCommSystem.timer);
+ }
}
- }
- );
+ );
+ }
},
/*
@@ -88,8 +94,18 @@
* Creates elements and populates with past info
*/
CheckSession: function() {
+ this.Focused='true';
+ Event.observe(document, 'focus', this.OnFocusEvent.bindAsEventListener(this));
+ Event.observe(document, 'blur', this.OnFocusEvent.bindAsEventListener(this));
window.clearTimeout(this.timer);
this.CommUpdate();
+ },
+
+ OnFocusEvent: function(evt) {
+ if(evt.type == "focus")
+ this.Focused='true';
+ else if(evt.type == "blur")
+ this.Focused='false';
},
/*
More information about the vtigercrm-commits
mailing list