Scroll down button: when scrolled up, or new non-visible message
FREEBIEpull/749/head
parent
13322c7071
commit
4c7bfbe9ff
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><g fill="none" fill-rule="evenodd"><path d="M0 0h48v48H0z"/><g stroke="#000" stroke-width="3.78"><path d="M24 6.41v32.814M38.29 23.028L24 39.226 9.706 23.028"/></g></g></svg>
|
After Width: | Height: | Size: 258 B |
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* vim: ts=4:sw=4:expandtab
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
window.Whisper = window.Whisper || {};
|
||||||
|
|
||||||
|
Whisper.ScrollDownButtonView = Whisper.View.extend({
|
||||||
|
className: 'scroll-down-button-view',
|
||||||
|
templateName: 'scroll-down-button-view',
|
||||||
|
|
||||||
|
initialize: function(options) {
|
||||||
|
options = options || {};
|
||||||
|
this.count = options.count || 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
increment: function(count) {
|
||||||
|
count = count || 0;
|
||||||
|
this.count += count;
|
||||||
|
this.render();
|
||||||
|
},
|
||||||
|
|
||||||
|
render_attributes: function() {
|
||||||
|
var cssClass = this.count > 0 ? 'new-messages' : '';
|
||||||
|
|
||||||
|
var moreBelow = i18n('scrollDown');
|
||||||
|
if (this.count > 1) {
|
||||||
|
moreBelow = i18n('messagesBelow');
|
||||||
|
} else if (this.count === 1) {
|
||||||
|
moreBelow = i18n('messageBelow');
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
cssClass: cssClass,
|
||||||
|
moreBelow: moreBelow
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* vim: ts=4:sw=4:expandtab
|
||||||
|
*/
|
||||||
|
describe('ScrollDownButtonView', function() {
|
||||||
|
// TODO: in electron branch, where we have access to real i18n, uncomment assertions against real strings
|
||||||
|
|
||||||
|
it('renders with count = 0', function() {
|
||||||
|
var view = new Whisper.ScrollDownButtonView();
|
||||||
|
view.render();
|
||||||
|
assert.equal(view.count, 0);
|
||||||
|
// assert.match(view.$el.html(), /Scroll to bottom/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders with count = 1', function() {
|
||||||
|
var view = new Whisper.ScrollDownButtonView({count: 1});
|
||||||
|
view.render();
|
||||||
|
assert.equal(view.count, 1);
|
||||||
|
assert.match(view.$el.html(), /new-messages/);
|
||||||
|
// assert.match(view.$el.html(), /New message below/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders with count = 2', function() {
|
||||||
|
var view = new Whisper.ScrollDownButtonView({count: 2});
|
||||||
|
view.render();
|
||||||
|
assert.equal(view.count, 2);
|
||||||
|
|
||||||
|
assert.match(view.$el.html(), /new-messages/);
|
||||||
|
// assert.match(view.$el.html(), /New messages below/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('increments count and re-renders', function() {
|
||||||
|
var view = new Whisper.ScrollDownButtonView();
|
||||||
|
view.render();
|
||||||
|
assert.equal(view.count, 0);
|
||||||
|
assert.notMatch(view.$el.html(), /new-messages/);
|
||||||
|
view.increment(1);
|
||||||
|
assert.equal(view.count, 1);
|
||||||
|
assert.match(view.$el.html(), /new-messages/);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue