2018-07-19 23:56:42 +08:00
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
2016-10-04 17:51:47 +08:00
|
|
|
$('.btn-more-notifications')
|
2018-07-19 23:56:42 +08:00
|
|
|
.on('ajax:success', function(e, data) {
|
2016-10-04 20:43:10 +08:00
|
|
|
var list = $('.notifications-list');
|
|
|
|
var moreBtn = $('.btn-more-notifications');
|
2016-10-04 17:51:47 +08:00
|
|
|
if (data.html) {
|
|
|
|
// Remove button if all notifications are shown
|
|
|
|
if (data.results_number < data.per_page) {
|
|
|
|
moreBtn.remove();
|
|
|
|
// Otherwise update reference
|
|
|
|
} else {
|
|
|
|
moreBtn.attr('href', data.more_notifications_url);
|
|
|
|
}
|
|
|
|
$(list).append(data.html);
|
2016-10-04 20:43:10 +08:00
|
|
|
} else if (data.results_number < 1) {
|
|
|
|
moreBtn.remove();
|
2016-10-04 17:51:47 +08:00
|
|
|
}
|
|
|
|
});
|
2018-07-19 23:56:42 +08:00
|
|
|
}());
|