s/routines/binders
Showing
3 changed files
with
28 additions
and
28 deletions
... | @@ -19,7 +19,7 @@ describe('Rivets.Binding', function() { | ... | @@ -19,7 +19,7 @@ describe('Rivets.Binding', function() { |
19 | }); | 19 | }); |
20 | 20 | ||
21 | it('gets assigned the proper binder routine matching the identifier', function() { | 21 | it('gets assigned the proper binder routine matching the identifier', function() { |
22 | expect(binding.binder.routine).toBe(rivets.routines.text); | 22 | expect(binding.binder.routine).toBe(rivets.binders.text); |
23 | }); | 23 | }); |
24 | 24 | ||
25 | describe('bind()', function() { | 25 | describe('bind()', function() { | ... | ... |
... | @@ -18,13 +18,13 @@ describe('Routines', function() { | ... | @@ -18,13 +18,13 @@ describe('Routines', function() { |
18 | 18 | ||
19 | describe('text', function() { | 19 | describe('text', function() { |
20 | it("sets the element's text content", function() { | 20 | it("sets the element's text content", function() { |
21 | rivets.routines.text(el, '<em>gluten-free</em>'); | 21 | rivets.binders.text(el, '<em>gluten-free</em>'); |
22 | expect(el.textContent || el.innerText).toBe('<em>gluten-free</em>'); | 22 | expect(el.textContent || el.innerText).toBe('<em>gluten-free</em>'); |
23 | expect(el.innerHTML).toBe('<em>gluten-free</em>'); | 23 | expect(el.innerHTML).toBe('<em>gluten-free</em>'); |
24 | }); | 24 | }); |
25 | 25 | ||
26 | it("sets the element's text content to zero when a numeric zero is passed", function() { | 26 | it("sets the element's text content to zero when a numeric zero is passed", function() { |
27 | rivets.routines.text(el, 0); | 27 | rivets.binders.text(el, 0); |
28 | expect(el.textContent || el.innerText).toBe('0'); | 28 | expect(el.textContent || el.innerText).toBe('0'); |
29 | expect(el.innerHTML).toBe('0'); | 29 | expect(el.innerHTML).toBe('0'); |
30 | }); | 30 | }); |
... | @@ -32,13 +32,13 @@ describe('Routines', function() { | ... | @@ -32,13 +32,13 @@ describe('Routines', function() { |
32 | 32 | ||
33 | describe('html', function() { | 33 | describe('html', function() { |
34 | it("sets the element's HTML content", function() { | 34 | it("sets the element's HTML content", function() { |
35 | rivets.routines.html(el, '<strong>fixie</strong>'); | 35 | rivets.binders.html(el, '<strong>fixie</strong>'); |
36 | expect(el.textContent || el.innerText).toBe('fixie'); | 36 | expect(el.textContent || el.innerText).toBe('fixie'); |
37 | expect(el.innerHTML).toBe('<strong>fixie</strong>'); | 37 | expect(el.innerHTML).toBe('<strong>fixie</strong>'); |
38 | }); | 38 | }); |
39 | 39 | ||
40 | it("sets the element's HTML content to zero when a zero value is passed", function() { | 40 | it("sets the element's HTML content to zero when a zero value is passed", function() { |
41 | rivets.routines.html(el, 0); | 41 | rivets.binders.html(el, 0); |
42 | expect(el.textContent || el.innerText).toBe('0'); | 42 | expect(el.textContent || el.innerText).toBe('0'); |
43 | expect(el.innerHTML).toBe('0'); | 43 | expect(el.innerHTML).toBe('0'); |
44 | }); | 44 | }); |
... | @@ -46,17 +46,17 @@ describe('Routines', function() { | ... | @@ -46,17 +46,17 @@ describe('Routines', function() { |
46 | 46 | ||
47 | describe('value', function() { | 47 | describe('value', function() { |
48 | it("sets the element's value", function() { | 48 | it("sets the element's value", function() { |
49 | rivets.routines.value.routine(input, 'pitchfork'); | 49 | rivets.binders.value.routine(input, 'pitchfork'); |
50 | expect(input.value).toBe('pitchfork'); | 50 | expect(input.value).toBe('pitchfork'); |
51 | }); | 51 | }); |
52 | 52 | ||
53 | it("applies a default value to the element when the model doesn't contain it", function() { | 53 | it("applies a default value to the element when the model doesn't contain it", function() { |
54 | rivets.routines.value.routine(input, undefined); | 54 | rivets.binders.value.routine(input, undefined); |
55 | expect(input.value).toBe(''); | 55 | expect(input.value).toBe(''); |
56 | }); | 56 | }); |
57 | 57 | ||
58 | it("sets the element's value to zero when a zero value is passed", function() { | 58 | it("sets the element's value to zero when a zero value is passed", function() { |
59 | rivets.routines.value.routine(input, 0); | 59 | rivets.binders.value.routine(input, 0); |
60 | expect(input.value).toBe('0'); | 60 | expect(input.value).toBe('0'); |
61 | }); | 61 | }); |
62 | }); | 62 | }); |
... | @@ -64,14 +64,14 @@ describe('Routines', function() { | ... | @@ -64,14 +64,14 @@ describe('Routines', function() { |
64 | describe('show', function() { | 64 | describe('show', function() { |
65 | describe('with a truthy value', function() { | 65 | describe('with a truthy value', function() { |
66 | it('shows the element', function() { | 66 | it('shows the element', function() { |
67 | rivets.routines.show(el, true); | 67 | rivets.binders.show(el, true); |
68 | expect(el.style.display).toBe(''); | 68 | expect(el.style.display).toBe(''); |
69 | }); | 69 | }); |
70 | }); | 70 | }); |
71 | 71 | ||
72 | describe('with a falsey value', function() { | 72 | describe('with a falsey value', function() { |
73 | it('hides the element', function() { | 73 | it('hides the element', function() { |
74 | rivets.routines.show(el, false); | 74 | rivets.binders.show(el, false); |
75 | expect(el.style.display).toBe('none'); | 75 | expect(el.style.display).toBe('none'); |
76 | }); | 76 | }); |
77 | }); | 77 | }); |
... | @@ -80,14 +80,14 @@ describe('Routines', function() { | ... | @@ -80,14 +80,14 @@ describe('Routines', function() { |
80 | describe('hide', function() { | 80 | describe('hide', function() { |
81 | describe('with a truthy value', function() { | 81 | describe('with a truthy value', function() { |
82 | it('hides the element', function() { | 82 | it('hides the element', function() { |
83 | rivets.routines.hide(el, true); | 83 | rivets.binders.hide(el, true); |
84 | expect(el.style.display).toBe('none'); | 84 | expect(el.style.display).toBe('none'); |
85 | }); | 85 | }); |
86 | }); | 86 | }); |
87 | 87 | ||
88 | describe('with a falsey value', function() { | 88 | describe('with a falsey value', function() { |
89 | it('shows the element', function() { | 89 | it('shows the element', function() { |
90 | rivets.routines.hide(el, false); | 90 | rivets.binders.hide(el, false); |
91 | expect(el.style.display).toBe(''); | 91 | expect(el.style.display).toBe(''); |
92 | }); | 92 | }); |
93 | }); | 93 | }); |
... | @@ -96,14 +96,14 @@ describe('Routines', function() { | ... | @@ -96,14 +96,14 @@ describe('Routines', function() { |
96 | describe('enabled', function() { | 96 | describe('enabled', function() { |
97 | describe('with a truthy value', function() { | 97 | describe('with a truthy value', function() { |
98 | it('enables the element', function() { | 98 | it('enables the element', function() { |
99 | rivets.routines.enabled(el, true); | 99 | rivets.binders.enabled(el, true); |
100 | expect(el.disabled).toBe(false); | 100 | expect(el.disabled).toBe(false); |
101 | }); | 101 | }); |
102 | }); | 102 | }); |
103 | 103 | ||
104 | describe('with a falsey value', function() { | 104 | describe('with a falsey value', function() { |
105 | it('disables the element', function() { | 105 | it('disables the element', function() { |
106 | rivets.routines.enabled(el, false); | 106 | rivets.binders.enabled(el, false); |
107 | expect(el.disabled).toBe(true); | 107 | expect(el.disabled).toBe(true); |
108 | }); | 108 | }); |
109 | }); | 109 | }); |
... | @@ -112,14 +112,14 @@ describe('Routines', function() { | ... | @@ -112,14 +112,14 @@ describe('Routines', function() { |
112 | describe('disabled', function() { | 112 | describe('disabled', function() { |
113 | describe('with a truthy value', function() { | 113 | describe('with a truthy value', function() { |
114 | it('disables the element', function() { | 114 | it('disables the element', function() { |
115 | rivets.routines.disabled(el, true); | 115 | rivets.binders.disabled(el, true); |
116 | expect(el.disabled).toBe(true); | 116 | expect(el.disabled).toBe(true); |
117 | }); | 117 | }); |
118 | }); | 118 | }); |
119 | 119 | ||
120 | describe('with a falsey value', function() { | 120 | describe('with a falsey value', function() { |
121 | it('enables the element', function() { | 121 | it('enables the element', function() { |
122 | rivets.routines.disabled(el, false); | 122 | rivets.binders.disabled(el, false); |
123 | expect(el.disabled).toBe(false); | 123 | expect(el.disabled).toBe(false); |
124 | }); | 124 | }); |
125 | }); | 125 | }); |
... | @@ -128,14 +128,14 @@ describe('Routines', function() { | ... | @@ -128,14 +128,14 @@ describe('Routines', function() { |
128 | describe('checked', function() { | 128 | describe('checked', function() { |
129 | describe('with a truthy value', function() { | 129 | describe('with a truthy value', function() { |
130 | it('checks the element', function() { | 130 | it('checks the element', function() { |
131 | rivets.routines.checked.routine(el, true); | 131 | rivets.binders.checked.routine(el, true); |
132 | expect(el.checked).toBe(true); | 132 | expect(el.checked).toBe(true); |
133 | }); | 133 | }); |
134 | }); | 134 | }); |
135 | 135 | ||
136 | describe('with a falsey value', function() { | 136 | describe('with a falsey value', function() { |
137 | it('unchecks the element', function() { | 137 | it('unchecks the element', function() { |
138 | rivets.routines.checked.routine(el, false); | 138 | rivets.binders.checked.routine(el, false); |
139 | expect(el.checked).toBe(false); | 139 | expect(el.checked).toBe(false); |
140 | }); | 140 | }); |
141 | }); | 141 | }); |
... | @@ -144,14 +144,14 @@ describe('Routines', function() { | ... | @@ -144,14 +144,14 @@ describe('Routines', function() { |
144 | describe('unchecked', function() { | 144 | describe('unchecked', function() { |
145 | describe('with a truthy value', function() { | 145 | describe('with a truthy value', function() { |
146 | it('unchecks the element', function() { | 146 | it('unchecks the element', function() { |
147 | rivets.routines.unchecked.routine(el, true); | 147 | rivets.binders.unchecked.routine(el, true); |
148 | expect(el.checked).toBe(false); | 148 | expect(el.checked).toBe(false); |
149 | }); | 149 | }); |
150 | }); | 150 | }); |
151 | 151 | ||
152 | describe('with a falsey value', function() { | 152 | describe('with a falsey value', function() { |
153 | it('checks the element', function() { | 153 | it('checks the element', function() { |
154 | rivets.routines.unchecked.routine(el, false); | 154 | rivets.binders.unchecked.routine(el, false); |
155 | expect(el.checked).toBe(true); | 155 | expect(el.checked).toBe(true); |
156 | }); | 156 | }); |
157 | }); | 157 | }); | ... | ... |
... | @@ -15,8 +15,8 @@ class Rivets.Binding | ... | @@ -15,8 +15,8 @@ class Rivets.Binding |
15 | # element, the type of binding, the model object and the keypath at which | 15 | # element, the type of binding, the model object and the keypath at which |
16 | # to listen for changes. | 16 | # to listen for changes. |
17 | constructor: (@el, @type, @model, @keypath, @options = {}) -> | 17 | constructor: (@el, @type, @model, @keypath, @options = {}) -> |
18 | unless @binder = Rivets.routines[type] | 18 | unless @binder = Rivets.binders[type] |
19 | for identifier, value of Rivets.routines | 19 | for identifier, value of Rivets.binders |
20 | if identifier isnt '*' and identifier.indexOf('*') isnt -1 | 20 | if identifier isnt '*' and identifier.indexOf('*') isnt -1 |
21 | regexp = new RegExp "^#{identifier.replace('*', '.+')}$" | 21 | regexp = new RegExp "^#{identifier.replace('*', '.+')}$" |
22 | if regexp.test type | 22 | if regexp.test type |
... | @@ -24,7 +24,7 @@ class Rivets.Binding | ... | @@ -24,7 +24,7 @@ class Rivets.Binding |
24 | @args = new RegExp("^#{identifier.replace('*', '(.+)')}$").exec type | 24 | @args = new RegExp("^#{identifier.replace('*', '(.+)')}$").exec type |
25 | @args.shift() | 25 | @args.shift() |
26 | 26 | ||
27 | @binder or= Rivets.routines['*'] | 27 | @binder or= Rivets.binders['*'] |
28 | 28 | ||
29 | if @binder instanceof Function | 29 | if @binder instanceof Function |
30 | @binder = {routine: @binder} | 30 | @binder = {routine: @binder} |
... | @@ -121,14 +121,14 @@ class Rivets.View | ... | @@ -121,14 +121,14 @@ class Rivets.View |
121 | for attribute in node.attributes | 121 | for attribute in node.attributes |
122 | if bindingRegExp.test attribute.name | 122 | if bindingRegExp.test attribute.name |
123 | type = attribute.name.replace bindingRegExp, '' | 123 | type = attribute.name.replace bindingRegExp, '' |
124 | unless binder = Rivets.routines[type] | 124 | unless binder = Rivets.binders[type] |
125 | for identifier, value of Rivets.routines | 125 | for identifier, value of Rivets.binders |
126 | if identifier isnt '*' and identifier.indexOf('*') isnt -1 | 126 | if identifier isnt '*' and identifier.indexOf('*') isnt -1 |
127 | regexp = new RegExp "^#{identifier.replace('*', '.+')}$" | 127 | regexp = new RegExp "^#{identifier.replace('*', '.+')}$" |
128 | if regexp.test type | 128 | if regexp.test type |
129 | binder = value | 129 | binder = value |
130 | 130 | ||
131 | binder or= Rivets.routines['*'] | 131 | binder or= Rivets.binders['*'] |
132 | 132 | ||
133 | if binder.block | 133 | if binder.block |
134 | skipNodes.push n for n in node.getElementsByTagName '*' | 134 | skipNodes.push n for n in node.getElementsByTagName '*' |
... | @@ -231,7 +231,7 @@ getInputValue = (el) -> | ... | @@ -231,7 +231,7 @@ getInputValue = (el) -> |
231 | else el.value | 231 | else el.value |
232 | 232 | ||
233 | # Core binding routines. | 233 | # Core binding routines. |
234 | Rivets.routines = | 234 | Rivets.binders = |
235 | enabled: (el, value) -> | 235 | enabled: (el, value) -> |
236 | el.disabled = !value | 236 | el.disabled = !value |
237 | 237 | ||
... | @@ -345,7 +345,7 @@ Rivets.formatters = {} | ... | @@ -345,7 +345,7 @@ Rivets.formatters = {} |
345 | # The rivets module. This is the public interface that gets exported. | 345 | # The rivets module. This is the public interface that gets exported. |
346 | rivets = | 346 | rivets = |
347 | # Exposes the core binding routines that can be extended or stripped down. | 347 | # Exposes the core binding routines that can be extended or stripped down. |
348 | routines: Rivets.routines | 348 | binders: Rivets.binders |
349 | 349 | ||
350 | # Exposes the formatters object to be extended. | 350 | # Exposes the formatters object to be extended. |
351 | formatters: Rivets.formatters | 351 | formatters: Rivets.formatters | ... | ... |
-
Please register or sign in to post a comment