Add Favio.js support. Fixes #28
This commit is contained in:
parent
2617dadb65
commit
a9d469867a
4 changed files with 32 additions and 4 deletions
|
@ -16,6 +16,7 @@
|
||||||
<script type="text/javascript" src="js/websockets.js"></script>
|
<script type="text/javascript" src="js/websockets.js"></script>
|
||||||
<script type="text/javascript" src="js/models.js"></script>
|
<script type="text/javascript" src="js/models.js"></script>
|
||||||
<script type="text/javascript" src="js/plugins.js"></script>
|
<script type="text/javascript" src="js/plugins.js"></script>
|
||||||
|
<script type="text/javascript" src="js/favico-0.3.0.min.js"></script>
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||||
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
7
js/favico-0.3.0.min.js
vendored
Normal file
7
js/favico-0.3.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -166,10 +166,11 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) {
|
||||||
});
|
});
|
||||||
|
|
||||||
activeBuffer.active = true;
|
activeBuffer.active = true;
|
||||||
activeBuffer.unread = '';
|
activeBuffer.unread = 0;
|
||||||
activeBuffer.notification = '';
|
activeBuffer.notification = 0;
|
||||||
|
|
||||||
$rootScope.$emit('activeBufferChanged');
|
$rootScope.$emit('activeBufferChanged');
|
||||||
|
$rootScope.$emit('notificationChanged');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -201,11 +201,13 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', functi
|
||||||
if (!initial) {
|
if (!initial) {
|
||||||
if (!buffer.active && _.contains(message.tags, 'notify_message') && !_.contains(message.tags, 'notify_none')) {
|
if (!buffer.active && _.contains(message.tags, 'notify_message') && !_.contains(message.tags, 'notify_none')) {
|
||||||
buffer.unread++;
|
buffer.unread++;
|
||||||
|
$rootScope.$emit('notificationChanged');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(message.highlight || _.contains(message.tags, 'notify_private') ) {
|
if(message.highlight || _.contains(message.tags, 'notify_private') ) {
|
||||||
buffer.notification++;
|
buffer.notification++;
|
||||||
$rootScope.createHighlight(buffer, message);
|
$rootScope.createHighlight(buffer, message);
|
||||||
|
$rootScope.$emit('notificationChanged');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,13 +426,29 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$rootScope.$on('activeBufferChanged', function() {
|
$rootScope.$on('activeBufferChanged', function() {
|
||||||
$rootScope.scrollToBottom();
|
$rootScope.scrollToBottom();
|
||||||
document.getElementById('sendMessage').focus();
|
document.getElementById('sendMessage').focus();
|
||||||
var ab = models.getActiveBuffer();
|
var ab = models.getActiveBuffer();
|
||||||
$rootScope.pageTitle = ab.shortName + ' | ' + ab.title;
|
$rootScope.pageTitle = ab.shortName + ' | ' + ab.title;
|
||||||
});
|
});
|
||||||
|
$rootScope.$on('notificationChanged', function() {
|
||||||
|
var notifications = _.reduce(models.model.buffers, function(memo, num) { return parseInt(memo||0) + num.notification;});
|
||||||
|
if (notifications > 0 ) {
|
||||||
|
$scope.favico = new Favico({
|
||||||
|
animation:'none'
|
||||||
|
});
|
||||||
|
$scope.favico.badge(notifications);
|
||||||
|
}else {
|
||||||
|
var unread = _.reduce(models.model.buffers, function(memo, num) { return parseInt(memo||0) + num.unread;});
|
||||||
|
$scope.favico = new Favico({
|
||||||
|
animation:'none',
|
||||||
|
bgColor : '#5CB85C',
|
||||||
|
textColor : '#ff0',
|
||||||
|
});
|
||||||
|
$scope.favico.badge(unread);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$scope.buffers = models.model.buffers;
|
$scope.buffers = models.model.buffers;
|
||||||
$scope.activeBuffer = models.getActiveBuffer
|
$scope.activeBuffer = models.getActiveBuffer
|
||||||
|
@ -506,7 +524,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
if (models.getActiveBuffer() == buffer) {
|
if (models.getActiveBuffer() == buffer) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return (parseInt(buffer.unread) || 0) > 0;
|
return buffer.unread > 0;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -556,5 +574,6 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue