signal-desktop/js/views/scroll_down_button_view.js

40 lines
850 B
JavaScript
Raw Normal View History

/* global Whisper, i18n */
// eslint-disable-next-line func-names
2018-04-27 21:25:04 +00:00
(function() {
'use strict';
2018-04-27 21:25:04 +00:00
window.Whisper = window.Whisper || {};
2018-04-27 21:25:04 +00:00
Whisper.ScrollDownButtonView = Whisper.View.extend({
className: 'module-scroll-down',
2018-04-27 21:25:04 +00:00
templateName: 'scroll-down-button-view',
initialize(options = {}) {
2018-04-27 21:25:04 +00:00
this.count = options.count || 0;
},
increment(count = 0) {
2018-04-27 21:25:04 +00:00
this.count += count;
this.render();
},
render_attributes() {
const buttonClass =
this.count > 0 ? 'module-scroll-down__button--new-messages' : '';
let moreBelow = i18n('scrollDown');
2018-04-27 21:25:04 +00:00
if (this.count > 1) {
moreBelow = i18n('messagesBelow');
} else if (this.count === 1) {
moreBelow = i18n('messageBelow');
}
2018-04-27 21:25:04 +00:00
return {
buttonClass,
moreBelow,
2018-04-27 21:25:04 +00:00
};
},
});
})();