206:d0bde0e3cc62
Anton Shestakov <av6@dwimlabs.net>, Wed, 01 Jun 2016 21:26:22 +0800
index: expand, but also deduplicate existence checks for previous and contact

next change 233:7d12b9fc2f41
previous change 78:32a3b275330a

js/favicon.js

Permissions: -rw-r--r--

Other formats: Feeds:
// Generated by CoffeeScript 1.10.0
(function() {
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;
window.Tram.FaviconApp = (function(superClass) {
extend(FaviconApp, superClass);
function FaviconApp() {
return FaviconApp.__super__.constructor.apply(this, arguments);
}
FaviconApp.prototype.tagName = 'link';
FaviconApp.prototype.attributes = {
rel: 'icon',
type: 'image/x-icon'
};
FaviconApp.prototype.pipColors = Tram.colors.show;
FaviconApp.prototype.initialize = function() {
this.canvas = document.createElement('canvas');
this.canvas.height = 16;
this.canvas.width = 16;
this.listenTo(this.model, 'change', this.updateFavicon);
this.updateFavicon();
return this.render();
};
FaviconApp.prototype.updateFavicon = function() {
var color, ref;
color = (ref = this.pipColors[this.model.get('show')]) != null ? ref : this.pipColors['default'];
return this.renderFavicon(color);
};
FaviconApp.prototype.renderFavicon = function(color) {
var ctx;
ctx = this.canvas.getContext('2d');
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(7.5, 7.5, 5.5, 0, Math.PI * 2);
ctx.fill();
return this.el.href = this.canvas.toDataURL();
};
FaviconApp.prototype.render = function() {
$('head').append(this.el);
return this;
};
return FaviconApp;
})(Backbone.View);
}).call(this);
//# sourceMappingURL=favicon.js.map