Anton Shestakov <av6@dwimlabs.net>, Tue, 19 Jun 2018 18:56:42 +0800
package.json: not for CoffeeScript 2
js/messages.js
Permissions: -rw-r--r--
// Generated by CoffeeScript 1.12.7 var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; Tram.Message = (function(superClass) { extend(Message, superClass); return Message.__super__.constructor.apply(this, arguments); Message.prototype.defaults = function() { Message.prototype.initialize = function() { return this.on('add change:stamp', function() { return this.set('d/mstamp', moment(this.get('stamp'))); Tram.Messages = (function(superClass) { extend(Messages, superClass); return Messages.__super__.constructor.apply(this, arguments); Messages.prototype.model = Tram.Message; Messages.prototype.splitThreshold = 30 * 60 * 1000; Messages.prototype.foldThreshold = 60 * 1000; Messages.prototype.comparator = function(model) { return model.get('stamp').valueOf(); Messages.prototype.initialize = function() { return this.on('add', this.onAdd); Messages.prototype.onAdd = function(model) { mi = this.indexOf(model); prev = this.models[mi - 1]; this._splitOrFold(prev, model); next = this.models[mi + 1]; return this._splitOrFold(model, next); Messages.prototype._splitOrFold = function(m1, m2) { if (this._splittable(m1, m2)) { return m2.set('d/split', true); if (this._foldable(m1, m2)) { return m2.set('d/fold', true); return m2.unset('d/fold'); Messages.prototype._splittable = function(m1, m2) { return Math.abs(m1.get('stamp').valueOf() - m2.get('stamp').valueOf()) > this.splitThreshold; Messages.prototype._foldable = function(m1, m2) { return m1.get('from') === m2.get('from') && Math.abs(m1.get('stamp').valueOf() - m2.get('stamp').valueOf()) < this.foldThreshold; Tram.MessageView = (function(superClass) { extend(MessageView, superClass); return MessageView.__super__.constructor.apply(this, arguments); MessageView.prototype.templateEl = $($('#message-template').html()); MessageView.prototype.initialize = function() { this.setElement(this.templateEl.clone()); this.$avatarColumn = this.$('.avatar-column'); MessageView.prototype.bind = function() { return this.listenTo(this.model, 'change:contact', this.updateContact); MessageView.prototype.updateContact = function() { if ((this.model.previous('contact') == null) && (this.model.get('contact') != null)) { this.av = new Tram.AvatarView({ return this.$avatarColumn.prepend(this.av.render().el); MessageView.prototype.render = function(model) { this.rivet = rivets.bind(this.el, { contact = this.model.get('contact'); this.av = new Tram.AvatarView({ this.$avatarColumn.prepend(this.av.render().el); MessageView.prototype.remove = function() { if ((ref = this.av) != null) { return MessageView.__super__.remove.apply(this, arguments); Tram.LogApp = (function(superClass) { extend(LogApp, superClass); return LogApp.__super__.constructor.apply(this, arguments); LogApp.prototype.templateEl = $($('#chat-template').html()); LogApp.prototype.initialize = function() { this.setElement(this.templateEl.clone()); this.$log = this.$('.log'); this.rivet = rivets.bind(this.el, { LogApp.prototype.bind = function() { return this.listenTo(this.collection, 'add', this.onAdd); LogApp.prototype.onAdd = function(model, collection) { var bottomed, el, mi, view; bottomed = this.bottomed(); mi = collection.indexOf(model); view = new Tram.MessageView({ this.$log.children().eq(mi - 1).after(el); LogApp.prototype.bottomed = function() { return this.$el.scrollTop() + this.$el.innerHeight() === this.el.scrollHeight; LogApp.prototype.scroll = function() { return this.$el.scrollTop(this.el.scrollHeight); LogApp.prototype.remove = function() { return LogApp.__super__.remove.apply(this, arguments); //# sourceMappingURL=messages.js.map