Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1936 from ajaxorg/add_doc_title_notification

* add document title notifications
  • Loading branch information...
commit cb93933e0a62fc31ba0414b9262c0f81d7f152c5 2 parents 690e77f + 20b5714
@linh81 linh81 authored
View
64 plugins-client/ext.dockpanel/dockpanel.js
@@ -28,6 +28,9 @@ module.exports = ext.register("ext/dockpanel/dockpanel", {
loaded : false,
+ initDocTitle : document.title,
+ notificationMsgs : {},
+
/**
* Standard Extension functionality
*/
@@ -428,9 +431,15 @@ module.exports = ext.register("ext/dockpanel/dockpanel", {
/**
* Updates the notification element to visually reflect notCount
*/
- updateNotificationElement: function(btnObj, count){
+ updateNotificationElement: function(btnObj, count, options){
var countInner = count === 0 ? "" : count;
var notificationEl = btnObj.$ext.getElementsByClassName("dock_notification")[0];
+
+ if(!options)
+ options = {};
+
+ var notificationType = options.type || "";
+
if (apf.isGecko)
notificationEl.textContent = countInner;
else
@@ -446,23 +455,74 @@ module.exports = ext.register("ext/dockpanel/dockpanel", {
btnPage.initCaption = btnPage.getAttribute("caption");
var caption = btnPage.initCaption;
-
+
if(!btnPage.$active) {
if (count > 0) {
caption += " (" + count + ")";
apf.setStyleClass(btnPage.$button, "un-read-message");
+ if(notificationType == "chat") {
+ btnObj.notificationOpt = options
+ if (options.name) {
+ this.notificationMsgs[options.name] = count;
+ this.updateDocTitleNotifications();
+ }
+ }
}
else {
apf.setStyleClass(btnPage.$button, "", ["un-read-message"]);
+ if(notificationType == "chat" && btnObj.notificationOpt) {
+ if (btnObj.notificationOpt && btnObj.notificationOpt.name) {
+ delete this.notificationMsgs[btnObj.notificationOpt.name];
+ this.updateDocTitleNotifications();
+ }
+ }
}
btnPage.setAttribute("caption", caption);
}
else {
btnPage.setAttribute("caption", caption);
apf.setStyleClass(btnPage.$button, "", ["un-read-message"]);
+ if(notificationType == "chat" && btnObj.notificationOpt) {
+ if (btnObj.notificationOpt && btnObj.notificationOpt.name) {
+ delete this.notificationMsgs[btnObj.notificationOpt.name];
+ this.updateDocTitleNotifications();
+ }
+ }
}
return true;
+ },
+
+ updateDocTitleNotifications: function(){
+ var _self = this,
+ countMsg = 0;
+
+ for(var i in this.notificationMsgs) {
+ if(this.notificationMsgs.hasOwnProperty(i))
+ countMsg += this.notificationMsgs[i];
+ }
+
+ if(countMsg > 0) {
+ if(this.barNotificationTimer)
+ clearInterval(this.barNotificationTimer);
+
+ this.barNotificationCount = 0;
+ this.barNotificationTimer = setInterval(function(){
+ if(_self.barNotificationCount%2)
+ document.title = "(" + countMsg + ") message" + (countMsg > 1 ? "s" : "") + " | " + _self.initDocTitle;
+ else
+ document.title = _self.initDocTitle;
+
+ _self.barNotificationCount++;
+ }, 1000);
+ }
+ else {
+ if(this.barNotificationTimer) {
+ clearInterval(this.barNotificationTimer);
+ this.barNotificationCount = 0;
+ document.title = _self.initDocTitle;
+ }
+ }
}
});
View
11 plugins-client/ext.dockpanel/libdock.js
@@ -2183,6 +2183,10 @@ var DockableLayout = module.exports = function(parentHBox, cbFindPage, cbStorePa
if (options && (tmp = options.primary)) {
var icoState = !this.value ? tmp.activeState : tmp.defaultState;
var span = button.$ext.getElementsByTagName("span");
+
+ if(!this.value)
+ this.$dockpage.$active = false;
+
span[2].style.backgroundPosition =
icoState.x + 'px '
+ icoState.y + 'px';
@@ -2216,6 +2220,9 @@ var DockableLayout = module.exports = function(parentHBox, cbFindPage, cbStorePa
var icoState = _btn.value ? tmp.activeState : tmp.defaultState;
var span = _btn.$ext.getElementsByTagName("span");
+ if(!_btn.value)
+ _btn.$dockpage.$active = false;
+
_btn.setAttribute("tooltip", options.menu.split("/").pop());
span[2].style.background = 'url("'
@@ -2263,6 +2270,10 @@ var DockableLayout = module.exports = function(parentHBox, cbFindPage, cbStorePa
if (options && (tmp = options.primary)) {
var icoState = button.value ? tmp.activeState : tmp.defaultState;
var span = button.$ext.getElementsByTagName("span");
+
+ if(!button.value)
+ button.$dockpage.$active = false;
+
span[2].style.backgroundPosition =
icoState.x + 'px '
+ icoState.y + 'px';
Please sign in to comment.
Something went wrong with that request. Please try again.