Download:
child 31:d0248d45562f
parent 29:8d134e4f876c
30:32d1f208206f
Anton Shestakov <av6@dwimlabs.net>, Mon, 21 Mar 2016 22:56:28 +0800
rivets: add missing formatters for contact chat state indicator

3 файлов изменено, 26 вставок(+), 1 удалений(-) [+]
coffee/rivets.coffee file | annotate | diff | comparison | revisions
js/rivets.js file | annotate | diff | comparison | revisions
js/rivets.js.map file | annotate | diff | comparison | revisions
--- a/coffee/rivets.coffee Mon Mar 21 21:46:23 2016 +0800
+++ b/coffee/rivets.coffee Mon Mar 21 22:56:28 2016 +0800
@@ -12,6 +12,14 @@
obj.set(keypath, value)
+rivets.formatters['only'] = (value, allowed...) ->
+ if value in allowed then value else ''
+
+
+rivets.formatters['eq'] = (a, b) ->
+ a is b
+
+
rivets.formatters['format-date'] = (value, format) ->
if value? then value.format(format) else ''
--- a/js/rivets.js Mon Mar 21 21:46:23 2016 +0800
+++ b/js/rivets.js Mon Mar 21 22:56:28 2016 +0800
@@ -1,5 +1,8 @@
// Generated by CoffeeScript 1.10.0
(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);
@@ -15,6 +18,20 @@
}
};
+ 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['format-date'] = function(value, format) {
if (value != null) {
return value.format(format);
--- a/js/rivets.js.map Mon Mar 21 21:46:23 2016 +0800
+++ b/js/rivets.js.map Mon Mar 21 22:56:28 2016 +0800
@@ -6,5 +6,5 @@
"coffee/rivets.coffee"
],
"names": [],
- "mappings": ";AAAA;EAAA,MAAM,CAAC,QAAS,CAA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