272:61421edbcb2b
Anton Shestakov <av6@dwimlabs.net>, Fri, 30 Dec 2016 23:47:11 +0800
index: show an unread messages indicator in document title

next change 291:923afdc60aaf
previous change 271:a015d1dba5cd

js/rivets.js

Permissions: -rw-r--r--

Other formats: Feeds:
// Generated by CoffeeScript 1.12.2
(function() {
var slice = [].slice,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
rivets.adapters[':'] = {
observe: function(obj, keypath, callback) {
return obj.on('change:' + keypath, callback);
},
unobserve: function(obj, keypath, callback) {
return obj.off('change:' + keypath, callback);
},
get: function(obj, keypath) {
return obj.get(keypath);
},
set: function(obj, keypath, value) {
return obj.set(keypath, value);
}
};
rivets.binders['style-*'] = function(el, value) {
return el.style[this.args[0]] = value != null ? value : '';
};
rivets.formatters['first-letter'] = function(value) {
var ref;
return (ref = value != null ? typeof value.charAt === "function" ? value.charAt(0) : void 0 : void 0) != null ? ref : ' ';
};
rivets.formatters['dumb-hash'] = function(value) {
var i, j, ref, result;
result = 0;
if (value != null ? value.length : void 0) {
for (i = j = 0, ref = value.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
result += value.charCodeAt(i);
}
}
return result;
};
rivets.formatters['fn'] = function(value, fn) {
return fn(value);
};
rivets.formatters['only'] = function() {
var allowed, value;
value = arguments[0], allowed = 2 <= arguments.length ? slice.call(arguments, 1) : [];
if (indexOf.call(allowed, value) >= 0) {
return value;
} else {
return '';
}
};
rivets.formatters['eq'] = function(a, b) {
return a === b;
};
rivets.formatters['has'] = function(a, b) {
return (a != null) && indexOf.call(a, b) >= 0;
};
rivets.formatters['format-date'] = function(value, format) {
if (value != null) {
return value.format(format);
} else {
return '';
}
};
rivets.formatters['iso-date'] = function(value) {
if (value != null) {
return value.toISOString();
} else {
return '';
}
};
rivets.formatters['from-now'] = function(value) {
if (value != null) {
return value.fromNow();
} else {
return '';
}
};
rivets.formatters['percent'] = function(value) {
return (value != null ? value : 0) + "%";
};
}).call(this);
//# sourceMappingURL=rivets.js.map