s/interface/adapter (interface is a reserved keyword in coffeescript 1.3.1).
Showing
2 changed files
with
22 additions
and
14 deletions
1 | // Generated by CoffeeScript 1.3.1 | ||
2 | (function() { | ||
1 | 3 | ||
2 | window.rivets = (function() { | 4 | window.rivets = (function() { |
3 | var attr, bindableAttributes, bindings, getInputValue, registerBinding, setAttribute, _fn, _i, _len; | 5 | var attr, bindableAttributes, bindings, getInputValue, registerBinding, setAttribute, _fn, _i, _len; |
4 | registerBinding = function(el, interface, type, context, keypath) { | 6 | registerBinding = function(el, adapter, type, context, keypath) { |
5 | var inputValue; | 7 | var inputValue; |
6 | bindings[type](el, interface.read(context, keypath)); | 8 | bindings[type](el, adapter.read(context, keypath)); |
7 | interface.subscribe(context, keypath, function(value) { | 9 | adapter.subscribe(context, keypath, function(value) { |
8 | return bindings[type](el, value); | 10 | return bindings[type](el, value); |
9 | }); | 11 | }); |
10 | if (inputValue = getInputValue(el)) { | 12 | if (inputValue = getInputValue(el)) { |
11 | return interface.publish(context, keypath, inputValue); | 13 | return adapter.publish(context, keypath, inputValue); |
12 | } | 14 | } |
13 | }; | 15 | }; |
14 | setAttribute = function(el, attr, value, mirrored) { | 16 | setAttribute = function(el, attr, value, mirrored) { |
15 | if (mirrored == null) mirrored = false; | 17 | if (mirrored == null) { |
18 | mirrored = false; | ||
19 | } | ||
16 | if (value) { | 20 | if (value) { |
17 | return $(el).attr(attr, mirrored ? attr : value); | 21 | return $(el).attr(attr, mirrored ? attr : value); |
18 | } else { | 22 | } else { |
... | @@ -81,8 +85,10 @@ | ... | @@ -81,8 +85,10 @@ |
81 | _fn(attr); | 85 | _fn(attr); |
82 | } | 86 | } |
83 | return { | 87 | return { |
84 | bind: function(el, interface, contexts) { | 88 | bind: function(el, adapter, contexts) { |
85 | if (contexts == null) contexts = {}; | 89 | if (contexts == null) { |
90 | contexts = {}; | ||
91 | } | ||
86 | return $(el).add($('*', el)).each(function() { | 92 | return $(el).add($('*', el)).each(function() { |
87 | var nodeMap, target, _j, _ref, _results; | 93 | var nodeMap, target, _j, _ref, _results; |
88 | target = this; | 94 | target = this; |
... | @@ -101,7 +107,7 @@ | ... | @@ -101,7 +107,7 @@ |
101 | path = node.value.split('.'); | 107 | path = node.value.split('.'); |
102 | context = path.shift(); | 108 | context = path.shift(); |
103 | keypath = path.join('.'); | 109 | keypath = path.join('.'); |
104 | return registerBinding($(target), interface, type, contexts[context], keypath); | 110 | return registerBinding($(target), adapter, type, contexts[context], keypath); |
105 | } | 111 | } |
106 | } | 112 | } |
107 | }); | 113 | }); |
... | @@ -110,3 +116,5 @@ | ... | @@ -110,3 +116,5 @@ |
110 | } | 116 | } |
111 | }; | 117 | }; |
112 | })(); | 118 | })(); |
119 | |||
120 | }).call(this); | ... | ... |
... | @@ -4,14 +4,14 @@ | ... | @@ -4,14 +4,14 @@ |
4 | # license : MIT | 4 | # license : MIT |
5 | 5 | ||
6 | window.rivets = do -> | 6 | window.rivets = do -> |
7 | registerBinding = (el, interface, type, context, keypath) -> | 7 | registerBinding = (el, adapter, type, context, keypath) -> |
8 | bindings[type] el, interface.read(context, keypath) | 8 | bindings[type] el, adapter.read(context, keypath) |
9 | 9 | ||
10 | interface.subscribe context, keypath, (value) -> | 10 | adapter.subscribe context, keypath, (value) -> |
11 | bindings[type] el, value | 11 | bindings[type] el, value |
12 | 12 | ||
13 | if inputValue = getInputValue el | 13 | if inputValue = getInputValue el |
14 | interface.publish context, keypath, inputValue | 14 | adapter.publish context, keypath, inputValue |
15 | 15 | ||
16 | setAttribute = (el, attr, value, mirrored=false) -> | 16 | setAttribute = (el, attr, value, mirrored=false) -> |
17 | if value | 17 | if value |
... | @@ -53,7 +53,7 @@ window.rivets = do -> | ... | @@ -53,7 +53,7 @@ window.rivets = do -> |
53 | bindings[attr] = (el, value) -> | 53 | bindings[attr] = (el, value) -> |
54 | setAttribute el, attr, value | 54 | setAttribute el, attr, value |
55 | 55 | ||
56 | bind: (el, interface, contexts={}) -> | 56 | bind: (el, adapter, contexts={}) -> |
57 | $(el).add($('*', el)).each -> | 57 | $(el).add($('*', el)).each -> |
58 | target = this | 58 | target = this |
59 | nodeMap = target.attributes | 59 | nodeMap = target.attributes |
... | @@ -69,4 +69,4 @@ window.rivets = do -> | ... | @@ -69,4 +69,4 @@ window.rivets = do -> |
69 | path = node.value.split '.' | 69 | path = node.value.split '.' |
70 | context = path.shift() | 70 | context = path.shift() |
71 | keypath = path.join '.' | 71 | keypath = path.join '.' |
72 | registerBinding $(target), interface, type, contexts[context], keypath | 72 | registerBinding $(target), adapter, type, contexts[context], keypath | ... | ... |
-
Please register or sign in to post a comment