2018-07-07 00:48:14 +00:00
|
|
|
/* global Whisper, i18n */
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
2018-04-27 21:25:04 +00:00
|
|
|
(function() {
|
|
|
|
'use strict';
|
2018-07-07 00:48:14 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
window.Whisper = window.Whisper || {};
|
2017-05-19 01:33:35 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
Whisper.ScrollDownButtonView = Whisper.View.extend({
|
2018-07-09 21:29:13 +00:00
|
|
|
className: 'module-scroll-down',
|
2018-04-27 21:25:04 +00:00
|
|
|
templateName: 'scroll-down-button-view',
|
2017-05-19 01:33:35 +00:00
|
|
|
|
2018-07-07 00:48:14 +00:00
|
|
|
initialize(options = {}) {
|
2018-04-27 21:25:04 +00:00
|
|
|
this.count = options.count || 0;
|
|
|
|
},
|
2017-05-19 01:33:35 +00:00
|
|
|
|
2018-07-07 00:48:14 +00:00
|
|
|
increment(count = 0) {
|
2018-04-27 21:25:04 +00:00
|
|
|
this.count += count;
|
|
|
|
this.render();
|
|
|
|
},
|
2017-05-19 01:33:35 +00:00
|
|
|
|
2018-07-07 00:48:14 +00:00
|
|
|
render_attributes() {
|
2018-07-09 21:29:13 +00:00
|
|
|
const buttonClass =
|
|
|
|
this.count > 0 ? 'module-scroll-down__button--new-messages' : '';
|
2017-05-19 01:33:35 +00:00
|
|
|
|
2018-07-07 00:48:14 +00:00
|
|
|
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');
|
|
|
|
}
|
2017-05-19 01:33:35 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
return {
|
2018-07-09 21:29:13 +00:00
|
|
|
buttonClass,
|
2018-07-07 00:48:14 +00:00
|
|
|
moreBelow,
|
2018-04-27 21:25:04 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2017-05-19 01:33:35 +00:00
|
|
|
})();
|